From: Lennart Poettering Date: Fri, 15 Sep 2017 12:17:32 +0000 (+0200) Subject: man: add a whole section detailing journal stdout/stderr stream logging X-Git-Tag: v235~92^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=157148d6d3bda380d08e4eec4de96f0db07c8dbd;p=platform%2Fupstream%2Fsystemd.git man: add a whole section detailing journal stdout/stderr stream logging Details about EPIPE/SIGPIPE handling, metadata and more. Fixes: #6620 --- diff --git a/man/systemd-journald.service.xml b/man/systemd-journald.service.xml index 2810638..559ef10 100644 --- a/man/systemd-journald.service.xml +++ b/man/systemd-journald.service.xml @@ -70,19 +70,18 @@ Kernel log messages, via kmsg - Simple system log messages, via the libc - syslog3 + Simple system log messages, via the libc syslog3 call Structured system log messages via the native Journal API, see sd_journal_print4 - Standard output and standard error of system - services + Standard output and standard error of service units. For further details see + below. - Audit records, via the audit - subsystem + Audit records, originating from the kernel audit subsystem The daemon will implicitly collect numerous metadata fields @@ -112,6 +111,49 @@ systemd-tmpfiles --create --prefix /var/log/journal + Stream logging + + The systemd service manager invokes all service processes with standard output and standard error connected + to the journal by default. This behaviour may be altered via the + StandardOutput=/StandardError= unit file settings, see + systemd.exec5 for details. The + journal converts the log byte stream received this way into individual log records, splitting the stream at newline + (\n, ASCII 10) and NUL bytes. + + If systemd-journald.service is stopped, the stream connections associated with all + services are terminated. Further writes to those streams by the service will result in EPIPE + errors. In order to react gracefully in this case it is recommended that programs logging to standard output/error + ignore such errors. If the the SIGPIPE UNIX signal handler is not blocked or turned off, such + write attempts will also result in such process signals being generated, see + signal7. To mitigate this issue, + systemd service manager explicitly turns off the SIGPIPE signal for all invoked processes by + default (this may be changed for each unit individually via the IgnoreSIGPIPE= option, see + systemd.exec5 for + details). After the standard output/standard error streams have been terminated they may not be recovered until the + services they are associated with are restarted. Note that during normal operation, + systemd-journald.service stores copies of the file descriptors for those streams in the + service manager. If systemd-journald.service is restarted using systemctl + restart or equivalent operation instead of a pair of separate systemctl stop and + systemctl start commands (or equivalent operations), these stream connections are not terminated + and survive the restart. It is thus safe to restart systemd-journald.service, but stopping it + is not recommended. + + Note that the log record metadata for records transferred via such standard output/error streams reflect the + metadata of the peer the stream was originally created for. If the stream connection is passed on to other + processes (such as further child processes forked off the main service process), the log records will not reflect + their metadata, but will continue to describe the original process. This is different from the other logging + transports listed above, which are inherently record based and where the metadata is always associated with the + individual record. + + In addition to the the implicit standard output/error logging of services, stream logging is also available + via the systemd-cat1 command + line tool. + + Currently, the number of parallel log streams systemd-journald will accept is limited + to 4096. + + + Signals