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