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