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