The log will be written to both /var/log/some-service as well as standard output.
The key is that s6-log reads in a whole "logging script" on the command line, and you can have multiple actions - here's the link to the manual.
S6_LOGGING_SCRIPT="T 1 n20 s1000000 T"
-
s6-log -bp
- calls6-log
in blocking, protected mode (same aslogutil-service
does) -
T 1
-- this is my first action directive- take all lines of input (because I don't have any line selection directives)
- prepend with an ISO 8601 timestamp (done with
T
) - forward to stdout (done with the
1
)
-
n20 s1000000 T /var/log/some-service
-- this is second first action directive, and it's the default mode forlogutil-service
- take all lines of input (again, no selection directives)
- keep up to 20 files (
n20
) - each file is max 1000000 bytes (
s1000000
) - prepend with an ISO 8601 timestamp (
T
) - save to logdir
/var/log/some-service
Ref: just-containers/s6-overlay#252
Simple
if { mkdir -p /var/log/myapp }
if { chown nobody:nogroup /var/log/myapp }
chmod 02755 /var/log/myapp
Custom
envfile /etc/myapp-env
importas myapp_version MYAPP_VERSION
foreground {
if { mkdir -p /var/log/myapp/$myapp_version }
if { chown nobody:nogroup /var/log/myapp/$myapp_version }
chmod 02755 /var/log/myapp/$myapp_version
}
# This line will be executed regardless of the exit status in the if above
echo "[INFO] myapp-log-prepare: The log files are stored in /var/log/myapp/$myapp_version"