]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd-journald.service.xml
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / man / systemd-journald.service.xml
CommitLineData
01cf0ca8
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
01cf0ca8
LP
4
5<!--
572eb058 6 SPDX-License-Identifier: LGPL-2.1+
01cf0ca8
LP
7-->
8
9<refentry id="systemd-journald.service">
10
798d3a52
ZJS
11 <refentryinfo>
12 <title>systemd-journald.service</title>
13 <productname>systemd</productname>
14
15 <authorgroup>
16 <author>
17 <contrib>Developer</contrib>
18 <firstname>Lennart</firstname>
19 <surname>Poettering</surname>
20 <email>lennart@poettering.net</email>
21 </author>
22 </authorgroup>
23 </refentryinfo>
24
25 <refmeta>
26 <refentrytitle>systemd-journald.service</refentrytitle>
27 <manvolnum>8</manvolnum>
28 </refmeta>
29
30 <refnamediv>
31 <refname>systemd-journald.service</refname>
32 <refname>systemd-journald.socket</refname>
33 <refname>systemd-journald-dev-log.socket</refname>
37b7affe 34 <refname>systemd-journald-audit.socket</refname>
798d3a52
ZJS
35 <refname>systemd-journald</refname>
36 <refpurpose>Journal service</refpurpose>
37 </refnamediv>
38
39 <refsynopsisdiv>
40 <para><filename>systemd-journald.service</filename></para>
41 <para><filename>systemd-journald.socket</filename></para>
42 <para><filename>systemd-journald-dev-log.socket</filename></para>
37b7affe 43 <para><filename>systemd-journald-audit.socket</filename></para>
12b42c76 44 <para><filename>/usr/lib/systemd/systemd-journald</filename></para>
798d3a52
ZJS
45 </refsynopsisdiv>
46
47 <refsect1>
48 <title>Description</title>
49
50 <para><filename>systemd-journald</filename> is a system service
51 that collects and stores logging data. It creates and maintains
52 structured, indexed journals based on logging information that is
53 received from a variety of sources:</para>
54
55 <itemizedlist>
56 <listitem><para>Kernel log messages, via kmsg</para></listitem>
57
157148d6
LP
58 <listitem><para>Simple system log messages, via the <filename>libc</filename> <citerefentry
59 project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52
ZJS
60 call</para></listitem>
61
62 <listitem><para>Structured system log messages via the native
63 Journal API, see
64 <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>4</manvolnum></citerefentry></para></listitem>
65
157148d6
LP
66 <listitem><para>Standard output and standard error of service units. For further details see
67 below.</para></listitem>
798d3a52 68
157148d6 69 <listitem><para>Audit records, originating from the kernel audit subsystem</para></listitem>
798d3a52
ZJS
70 </itemizedlist>
71
72 <para>The daemon will implicitly collect numerous metadata fields
73 for each log messages in a secure and unfakeable way. See
74 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
75 for more information about the collected metadata.
76 </para>
77
fc5f5706
LP
78 <para>Log data collected by the journal is primarily text-based but can also include binary data where
79 necessary. Individual fields making up a log record stored in the journal may be up to 2^64-1 bytes in size.</para>
80
81 <para>The journal service stores log data either persistently below <filename>/var/log/journal</filename> or in a
82 volatile way below <filename>/run/log/journal/</filename> (in the latter case it is lost at reboot). By default, log
83 data is stored persistently if <filename>/var/log/journal/</filename> exists during boot, with an implicit fallback
84 to volatile storage otherwise. Use <varname>Storage=</varname> in
85 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> to configure
86 where log data is placed, independently of the existence of <filename>/var/log/journal/</filename>.</para>
87
88 <para>On systems where <filename>/var/log/journal/</filename> does not exist yet but where persistent logging is
89 desired (and the default <filename>journald.conf</filename> is used), it is sufficient to create the directory, and
90 ensure it has the correct access modes and ownership:</para>
c214ee6f
EV
91
92 <programlisting>mkdir -p /var/log/journal
93systemd-tmpfiles --create --prefix /var/log/journal</programlisting>
798d3a52 94
798d3a52
ZJS
95 <para>See
96 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
97 for information about the configuration of this service.</para>
98 </refsect1>
99
157148d6
LP
100 <refsect1>
101 <title>Stream logging</title>
102
103 <para>The systemd service manager invokes all service processes with standard output and standard error connected
104 to the journal by default. This behaviour may be altered via the
105 <varname>StandardOutput=</varname>/<varname>StandardError=</varname> unit file settings, see
106 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for details. The
107 journal converts the log byte stream received this way into individual log records, splitting the stream at newline
108 (<literal>\n</literal>, ASCII <constant>10</constant>) and <constant>NUL</constant> bytes.</para>
109
110 <para>If <filename>systemd-journald.service</filename> is stopped, the stream connections associated with all
111 services are terminated. Further writes to those streams by the service will result in <constant>EPIPE</constant>
112 errors. In order to react gracefully in this case it is recommended that programs logging to standard output/error
dcfaecc7 113 ignore such errors. If the <constant>SIGPIPE</constant> UNIX signal handler is not blocked or turned off, such
157148d6
LP
114 write attempts will also result in such process signals being generated, see
115 <citerefentry><refentrytitle>signal</refentrytitle><manvolnum>7</manvolnum></citerefentry>. To mitigate this issue,
116 systemd service manager explicitly turns off the <constant>SIGPIPE</constant> signal for all invoked processes by
117 default (this may be changed for each unit individually via the <varname>IgnoreSIGPIPE=</varname> option, see
118 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
119 details). After the standard output/standard error streams have been terminated they may not be recovered until the
120 services they are associated with are restarted. Note that during normal operation,
121 <filename>systemd-journald.service</filename> stores copies of the file descriptors for those streams in the
122 service manager. If <filename>systemd-journald.service</filename> is restarted using <command>systemctl
123 restart</command> or equivalent operation instead of a pair of separate <command>systemctl stop</command> and
124 <command>systemctl start</command> commands (or equivalent operations), these stream connections are not terminated
125 and survive the restart. It is thus safe to restart <filename>systemd-journald.service</filename>, but stopping it
126 is not recommended.</para>
127
128 <para>Note that the log record metadata for records transferred via such standard output/error streams reflect the
129 metadata of the peer the stream was originally created for. If the stream connection is passed on to other
130 processes (such as further child processes forked off the main service process), the log records will not reflect
131 their metadata, but will continue to describe the original process. This is different from the other logging
132 transports listed above, which are inherently record based and where the metadata is always associated with the
133 individual record.</para>
134
dcfaecc7 135 <para>In addition to the implicit standard output/error logging of services, stream logging is also available
157148d6
LP
136 via the <citerefentry><refentrytitle>systemd-cat</refentrytitle><manvolnum>1</manvolnum></citerefentry> command
137 line tool.</para>
138
ec20fe5f 139 <para>Currently, the number of parallel log streams <filename>systemd-journald</filename> will accept is limited to
dcfaecc7 140 4096. When this limit is reached further log streams may be established but will receive
ec20fe5f 141 <constant>EPIPE</constant> right from the beginning.</para>
157148d6
LP
142 </refsect1>
143
798d3a52
ZJS
144 <refsect1>
145 <title>Signals</title>
146
147 <variablelist>
148 <varlistentry>
149 <term>SIGUSR1</term>
150
151 <listitem><para>Request that journal data from
152 <filename>/run/</filename> is flushed to
153 <filename>/var/</filename> in order to make it persistent (if
154 this is enabled). This must be used after
155 <filename>/var/</filename> is mounted, as otherwise log data
156 from <filename>/run</filename> is never flushed to
94b65516
LP
157 <filename>/var</filename> regardless of the configuration. The
158 <command>journalctl --flush</command> command uses this signal
159 to request flushing of the journal files, and then waits for
160 the operation to complete. See
161 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
162 for details.</para></listitem>
798d3a52
ZJS
163 </varlistentry>
164
165 <varlistentry>
166 <term>SIGUSR2</term>
167
168 <listitem><para>Request immediate rotation of the journal
94b65516
LP
169 files. The <command>journalctl --rotate</command> command uses
170 this signal to request journal file
171 rotation.</para></listitem>
172 </varlistentry>
173
174 <varlistentry>
175 <term>SIGRTMIN+1</term>
176
177 <listitem><para>Request that all unwritten log data is written
178 to disk. The <command>journalctl --sync</command> command uses
179 this signal to trigger journal synchronization, and then waits
180 for the operation to complete.</para></listitem>
798d3a52
ZJS
181 </varlistentry>
182 </variablelist>
183 </refsect1>
184
185 <refsect1>
186 <title>Kernel Command Line</title>
187
188 <para>A few configuration parameters from
189 <filename>journald.conf</filename> may be overridden on the kernel
190 command line:</para>
191
192 <variablelist class='kernel-commandline-options'>
193 <varlistentry>
194 <term><varname>systemd.journald.forward_to_syslog=</varname></term>
195 <term><varname>systemd.journald.forward_to_kmsg=</varname></term>
196 <term><varname>systemd.journald.forward_to_console=</varname></term>
197 <term><varname>systemd.journald.forward_to_wall=</varname></term>
198
199 <listitem><para>Enables/disables forwarding of collected log
200 messages to syslog, the kernel log buffer, the system console
201 or wall.
202 </para>
203
204 <para>See
205 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
206 for information about these settings.</para>
207 </listitem>
208
209 </varlistentry>
210 </variablelist>
211 </refsect1>
212
213 <refsect1>
214 <title>Access Control</title>
215
216 <para>Journal files are, by default, owned and readable by the
217 <literal>systemd-journal</literal> system group but are not
218 writable. Adding a user to this group thus enables her/him to read
219 the journal files.</para>
220
221 <para>By default, each logged in user will get her/his own set of
222 journal files in <filename>/var/log/journal/</filename>. These
223 files will not be owned by the user, however, in order to avoid
224 that the user can write to them directly. Instead, file system
225 ACLs are used to ensure the user gets read access only.</para>
226
227 <para>Additional users and groups may be granted access to journal
228 files via file system access control lists (ACL). Distributions
229 and administrators may choose to grant read access to all members
230 of the <literal>wheel</literal> and <literal>adm</literal> system
231 groups with a command such as the following:</para>
232
233 <programlisting># setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/</programlisting>
234
235 <para>Note that this command will update the ACLs both for
236 existing journal files and for future journal files created in the
237 <filename>/var/log/journal/</filename> directory.</para>
238 </refsect1>
239
240 <refsect1>
241 <title>Files</title>
242
243 <variablelist>
244 <varlistentry>
12b42c76 245 <term><filename>/etc/systemd/journald.conf</filename></term>
798d3a52 246
4bb890bc 247 <listitem><para>Configure <command>systemd-journald</command> behavior. See
798d3a52
ZJS
248 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
249 </para></listitem>
250 </varlistentry>
251
252 <varlistentry>
253 <term><filename>/run/log/journal/<replaceable>machine-id</replaceable>/*.journal</filename></term>
254 <term><filename>/run/log/journal/<replaceable>machine-id</replaceable>/*.journal~</filename></term>
255 <term><filename>/var/log/journal/<replaceable>machine-id</replaceable>/*.journal</filename></term>
256 <term><filename>/var/log/journal/<replaceable>machine-id</replaceable>/*.journal~</filename></term>
257
4bb890bc 258 <listitem><para><command>systemd-journald</command> writes entries to files in
798d3a52
ZJS
259 <filename>/run/log/journal/<replaceable>machine-id</replaceable>/</filename>
260 or
261 <filename>/var/log/journal/<replaceable>machine-id</replaceable>/</filename>
262 with the <literal>.journal</literal> suffix. If the daemon is
263 stopped uncleanly, or if the files are found to be corrupted,
264 they are renamed using the <literal>.journal~</literal>
265 suffix, and <command>systemd-journald</command> starts writing
266 to a new file. <filename>/run</filename> is used when
267 <filename>/var/log/journal</filename> is not available, or
268 when <option>Storage=volatile</option> is set in the
269 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
4bb890bc
ZJS
270 configuration file.</para>
271
272 <para>When <filename>systemd-journald</filename> ceases writing to a journal file,
273 it will be renamed to <literal><replaceable>original-name</replaceable>@<replaceable>suffix.journal</replaceable></literal>
274 (or <literal><replaceable>original-name</replaceable>@<replaceable>suffix.journal~</replaceable></literal>).
275 Such files are "archived" and will not be written to any more.</para>
276
277 <para>In general, it is safe to read or copy any journal file (active or archived).
278 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
279 and the functions in the
280 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>
281 library should be able to read all entries that have been fully written.</para>
752ce396
ZJS
282
283 <para><filename>systemd-journald</filename> will automatically remove the oldest
284 archived journal files to limit disk use. See <varname>SystemMaxUse=</varname>
285 and related settings in
286 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
287 </para></listitem>
37b7affe
ZJS
288 </varlistentry>
289
290 <varlistentry>
291 <term><filename>/dev/kmsg</filename></term>
292 <term><filename>/dev/log</filename></term>
293 <term><filename>/run/systemd/journal/dev-log</filename></term>
294 <term><filename>/run/systemd/journal/socket</filename></term>
295 <term><filename>/run/systemd/journal/stdout</filename></term>
296
e296313f 297 <listitem><para>Sockets and other paths that
37b7affe 298 <command>systemd-journald</command> will listen on that are
a8eaaee7 299 visible in the file system. In addition to these, journald can
37b7affe 300 listen for audit events using netlink.</para></listitem>
798d3a52
ZJS
301 </varlistentry>
302 </variablelist>
303 </refsect1>
304
305 <refsect1>
306 <title>See Also</title>
307 <para>
308 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
309 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
310 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
311 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
312 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
313 <citerefentry><refentrytitle>systemd-coredump</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
3ba3a79d 314 <citerefentry project='die-net'><refentrytitle>setfacl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
798d3a52 315 <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>4</manvolnum></citerefentry>,
94b65516 316 <command>pydoc systemd.journal</command>
798d3a52
ZJS
317 </para>
318 </refsect1>
01cf0ca8
LP
319
320</refentry>