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