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