log: Add support for the systemd journal

The journal is a component of systemd, that captures Syslog messages,
Kernel log messages, initial RAM disk and early boot messages as well
as messages written to STDOUT/STDERR of all services, indexes them and
makes this available to the user.

It can be used in parallel, or in place of a traditional syslog daemon,
such as rsyslog or syslog-ng.

The journal offers a couple of improvements over traditional logging
facilities (e.g. advanced filtering capabilities).

This patch adds support for logging directly to the journal using its
native API.
This commit is contained in:
poljar (Damir Jelić) 2013-12-03 01:09:56 +01:00 committed by Peter Meerwald
parent a8fea5c468
commit d20ee7e7f2
8 changed files with 113 additions and 19 deletions

View file

@ -297,11 +297,12 @@ USA.
<option>
<p><opt>log-target=</opt> The default log target. Use either
<opt>stderr</opt>, <opt>syslog</opt>, <opt>auto</opt>,
<opt>file:PATH</opt> or <opt>newfile:PATH</opt>. <opt>auto</opt> is
equivalent to <opt>sylog</opt> in case <opt>daemonize</opt> is enabled,
otherwise to <opt>stderr</opt>. If set to <opt>file:PATH</opt>, logging
is directed to the file indicated by PATH. <opt>newfile:PATH</opt> is
<opt>stderr</opt>, <opt>syslog</opt>, <opt>journal</opt> (optional),
<opt>auto</opt>, <opt>file:PATH</opt> or <opt>newfile:PATH</opt>. On traditional
systems <opt>auto</opt> is equivalent to <opt>syslog</opt>. On systemd-enabled
systems, auto is equivalent to <opt>journal</opt>, in case <opt>daemonize</opt>
is enabled, and to <opt>stderr</opt> otherwise. If set to <opt>file:PATH</opt>,
logging is directed to the file indicated by PATH. <opt>newfile:PATH</opt> is
otherwise the same as <opt>file:PATH</opt>, but existing files are never
overwritten. If the specified file already exists, a suffix is added to
the file name to avoid overwriting. Defaults to <opt>auto</opt>. The

View file

@ -217,12 +217,13 @@ USA.
</option>
<option>
<p><opt>--log-target</opt><arg>={auto,syslog,stderr,file:PATH,newfile:PATH}</arg></p>
<p><opt>--log-target</opt><arg>={auto,syslog,journal,stderr,file:PATH,newfile:PATH}</arg></p>
<optdesc><p>Specify the log target. If set to <arg>auto</arg>
(which is the default), then logging is directed to syslog when
<opt>--daemonize</opt> is passed, otherwise to
STDERR. If set to <arg>file:PATH</arg>, logging is directed to
STDERR. If set to <arg>journal</arg> logging is directed to the systemd
journal. If set to <arg>file:PATH</arg>, logging is directed to
the file indicated by PATH. <arg>newfile:PATH</arg> is otherwise
the same as file:PATH, but existing files are never overwritten.
If the specified file already exists, a suffix is added to the