chiark / gitweb /
man: fix compilation of example
[elogind.git] / man / journalctl.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   This file is part of systemd.
7
8   Copyright 2012 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="journalctl">
25
26         <refentryinfo>
27                 <title>journalctl</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>journalctl</refentrytitle>
42                 <manvolnum>1</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>journalctl</refname>
47                 <refpurpose>Query the systemd journal</refpurpose>
48         </refnamediv>
49
50         <refsynopsisdiv>
51                 <cmdsynopsis>
52                         <command>journalctl <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">MATCHES</arg></command>
53                 </cmdsynopsis>
54         </refsynopsisdiv>
55
56         <refsect1>
57                 <title>Description</title>
58
59                 <para><command>journalctl</command> may be used to
60                 query the contents of the
61                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
62                 journal as written by
63                 <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
64
65                 <para>If called without parameter it will show the full
66                 contents of the journal, starting with the oldest
67                 entry collected.</para>
68
69                 <para>If one or more match arguments are passed the
70                 output is filtered accordingly. A match is in the
71                 format <literal>FIELD=VALUE</literal>,
72                 e.g. <literal>_SYSTEMD_UNIT=httpd.service</literal>,
73                 referring to the components of a structured journal
74                 entry. See
75                 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
76                 for a list of well-known fields. If multiple matches
77                 are specified matching different fields the log
78                 entries are filtered by both, i.e. the resulting output
79                 will show only entries matching all the specified
80                 matches of this kind. If two matches apply to the same
81                 field, then they are automatically matched as
82                 alternatives, i.e. the resulting output will show
83                 entries matching any of the specified matches for the
84                 same field. Finally, if the character
85                 "<literal>+</literal>" appears as separate word on the
86                 command line all matches before and after are combined
87                 in a disjunction (i.e. logical OR).</para>
88
89                 <para>As shortcuts for a few types of field/value
90                 matches file paths may be specified. If a file path
91                 refers to an executable file, this is equivalent to an
92                 <literal>_EXE=</literal> match for the canonicalized
93                 binary path. Similar, if a path refers to a device
94                 node, this is equivalent to a
95                 <literal>_KERNEL_DEVICE=</literal> match for the
96                 device.</para>
97
98                 <para>Output is interleaved from all accessible
99                 journal files, whether they are rotated or currently
100                 being written, and regardless whether they belong to the
101                 system itself or are accessible user journals.</para>
102
103                 <para>All users are granted access to their private
104                 per-user journals. However, by default only root and
105                 users who are members of the <literal>adm</literal>
106                 group get access to the system journal and the
107                 journals of other users.</para>
108         </refsect1>
109
110         <refsect1>
111                 <title>Options</title>
112
113                 <para>The following options are understood:</para>
114
115                 <variablelist>
116                         <varlistentry>
117                                 <term><option>-h</option></term>
118                                 <term><option>--help</option></term>
119
120                                 <listitem><para>Prints a short help
121                                 text and exits.</para></listitem>
122                         </varlistentry>
123
124                         <varlistentry>
125                                 <term><option>--version</option></term>
126
127                                 <listitem><para>Prints a short version
128                                 string and exits.</para></listitem>
129                         </varlistentry>
130
131                         <varlistentry>
132                                 <term><option>--no-pager</option></term>
133
134                                 <listitem><para>Do not pipe output into a
135                                 pager.</para></listitem>
136                         </varlistentry>
137
138                         <varlistentry>
139                                 <term><option>--full</option></term>
140
141                                 <listitem><para>Show all (printable) fields in
142                                 full.</para></listitem>
143                         </varlistentry>
144
145                         <varlistentry>
146                                 <term><option>-a</option></term>
147                                 <term><option>--all</option></term>
148
149                                 <listitem><para>Show all fields in
150                                 full, even if they include unprintable
151                                 characters or are very
152                                 long.</para></listitem>
153                         </varlistentry>
154
155                         <varlistentry>
156                                 <term><option>-f</option></term>
157                                 <term><option>--follow</option></term>
158
159                                 <listitem><para>Show only the most recent
160                                 journal entries, and continuously print
161                                 new entries as they are appended to
162                                 the journal.</para></listitem>
163                         </varlistentry>
164
165                         <varlistentry>
166                                 <term><option>-n</option></term>
167                                 <term><option>--lines=</option></term>
168
169                                 <listitem><para>Show the most recent
170                                 journal events and limit the number of
171                                 events shown. If
172                                 <option>--follow</option> is used,
173                                 this option is implied. The argument,
174                                 a positive integer, is optional, and
175                                 defaults to 10. </para></listitem>
176                         </varlistentry>
177
178                         <varlistentry>
179                                 <term><option>--no-tail</option></term>
180
181                                 <listitem><para>Show all stored output
182                                 lines, even in follow mode. Undoes the
183                                 effect of
184                                 <option>--lines=</option>.</para></listitem>
185                         </varlistentry>
186
187                         <varlistentry>
188                                 <term><option>-r</option></term>
189                                 <term><option>--reverse</option></term>
190
191                                 <listitem><para>Reverse output, so the newest
192                                 entries are displayed first.</para></listitem>
193                         </varlistentry>
194
195                         <varlistentry>
196                                 <term><option>-o</option></term>
197                                 <term><option>--output=</option></term>
198
199                                 <listitem><para>Controls the
200                                 formatting of the journal entries that
201                                 are shown. Takes one of
202                                 <literal>short</literal>,
203                                 <literal>short-monotonic</literal>,
204                                 <literal>verbose</literal>,
205                                 <literal>export</literal>,
206                                 <literal>json</literal>,
207                                 <literal>json-pretty</literal>,
208                                 <literal>json-sse</literal>,
209                                 <literal>cat</literal>. <literal>short</literal>
210                                 is the default and generates an output
211                                 that is mostly identical to the
212                                 formatting of classic syslog log
213                                 files, showing one line per journal
214                                 entry. <literal>short-monotonic</literal>
215                                 is very similar but shows monotonic
216                                 timestamps instead of wallclock
217                                 timestamps. <literal>verbose</literal>
218                                 shows the full structured entry items
219                                 with all
220                                 fields. <literal>export</literal>
221                                 serializes the journal into a binary
222                                 (but mostly text-based) stream
223                                 suitable for backups and network
224                                 transfer (see <ulink
225                                 url="http://www.freedesktop.org/wiki/Software/systemd/export">Journal
226                                 Export Format</ulink> for more
227                                 information). <literal>json</literal>
228                                 formats entries as JSON data
229                                 structures, one per
230                                 line (see <ulink
231                                 url="http://www.freedesktop.org/wiki/Software/systemd/json">Journal
232                                 JSON Format</ulink> for more
233                                 information). <literal>json-pretty</literal>
234                                 also formats entries as JSON data
235                                 structures, but formats them in
236                                 multiple lines in order to make them
237                                 more readable for
238                                 humans. <literal>json-sse</literal>
239                                 also formats entries as JSON data
240                                 structures, but wraps them in a format
241                                 suitable for <ulink
242                                 url="https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events">Server-Sent
243                                 Events</ulink>. <literal>cat</literal>
244                                 generates a very terse output only
245                                 showing the actual message of each
246                                 journal entry with no meta data, not
247                                 even a timestamp.</para></listitem>
248                         </varlistentry>
249
250                         <varlistentry>
251                                 <term><option>-x</option></term>
252                                 <term><option>--catalog</option></term>
253
254                                 <listitem><para>Augment log lines with
255                                 explanation texts from the message
256                                 catalog. This will add explanatory
257                                 help texts to log messages in the
258                                 output where this is available. These
259                                 short help texts will explain the
260                                 context of an error or log event,
261                                 possible solutions, as well as
262                                 pointers to support forums, developer
263                                 documentation and any other relevant
264                                 manuals. Note that help texts are not
265                                 available for all messages, but only
266                                 for selected ones. For more
267                                 information on the message catalog
268                                 please refer to the <ulink
269                                 url="http://www.freedesktop.org/wiki/Software/systemd/catalog">Message
270                                 Catalog Developer
271                                 Documentation</ulink>.</para></listitem>
272                         </varlistentry>
273
274                         <varlistentry>
275                                 <term><option>-q</option></term>
276                                 <term><option>--quiet</option></term>
277
278                                 <listitem><para>Suppresses any warning
279                                 message regarding inaccessible system
280                                 journals when run as normal
281                                 user.</para></listitem>
282                         </varlistentry>
283
284                         <varlistentry>
285                                 <term><option>-m</option></term>
286                                 <term><option>--merge</option></term>
287
288                                 <listitem><para>Show entries
289                                 interleaved from all available
290                                 journals, including remote
291                                 ones.</para></listitem>
292                         </varlistentry>
293
294                         <varlistentry>
295                                 <term><option>-b</option></term>
296                                 <term><option>--this-boot</option></term>
297
298                                 <listitem><para>Show data only from
299                                 current boot. This will add a match
300                                 for <literal>_BOOT_ID=</literal> for
301                                 the current boot ID of the
302                                 kernel.</para></listitem>
303                         </varlistentry>
304
305                         <varlistentry>
306                                 <term><option>-u</option></term>
307                                 <term><option>--unit=</option></term>
308
309                                 <listitem><para>Show data only of the
310                                 specified unit. This will add a match
311                                 for <literal>_SYSTEMD_UNIT=</literal>
312                                 for the specified
313                                 unit.</para></listitem>
314                         </varlistentry>
315
316                         <varlistentry>
317                                 <term><option>--user-unit=</option></term>
318
319                                 <listitem><para>Show data only of the
320                                 specified user session unit. This will
321                                 add a match for
322                                 <literal>_SYSTEMD_USER_UNIT=</literal>
323                                 for the specified
324                                 unit.</para></listitem>
325                         </varlistentry>
326
327                         <varlistentry>
328                                 <term><option>-p</option></term>
329                                 <term><option>--priority=</option></term>
330
331                                 <listitem><para>Filter output by
332                                 message priorities or priority
333                                 ranges. Takes either a single numeric
334                                 or textual log level (i.e. between
335                                 0/<literal>emerg</literal> and
336                                 7/<literal>debug</literal>), or a
337                                 range of numeric/text log levels in
338                                 the form FROM..TO. The log levels are
339                                 the usual syslog log levels as
340                                 documented in
341                                 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
342                                 i.e. <literal>emerg</literal> (0),
343                                 <literal>alert</literal> (1),
344                                 <literal>crit</literal> (2),
345                                 <literal>err</literal> (3),
346                                 <literal>warning</literal> (4),
347                                 <literal>notice</literal> (5),
348                                 <literal>info</literal> (6),
349                                 <literal>debug</literal> (7). If a
350                                 single log level is specified all
351                                 messages with this log level or a
352                                 lower (hence more important) log level
353                                 are shown. If a range is specified all
354                                 messages within the range are shown,
355                                 including both the start and the end
356                                 value of the range. This will add
357                                 <literal>PRIORITY=</literal> matches
358                                 for the specified
359                                 priorities.</para></listitem>
360                         </varlistentry>
361
362                         <varlistentry>
363                                 <term><option>-c</option></term>
364                                 <term><option>--cursor=</option></term>
365
366                                 <listitem><para>Start showing entries
367                                 from the location in the journal
368                                 specified by the passed
369                                 cursor.</para></listitem>
370                         </varlistentry>
371
372                         <varlistentry>
373                                 <term><option>--since=</option></term>
374                                 <term><option>--until=</option></term>
375
376                                 <listitem><para>Start showing entries
377                                 on or newer than the specified date,
378                                 or on or older than the specified
379                                 date, respectively. Date specifications should be of
380                                 the format "2012-10-30 18:17:16". If
381                                 the time part is omitted, 00:00:00 is
382                                 assumed. If only the seconds component
383                                 is omitted, :00 is assumed. If the
384                                 date component is omitted, the
385                                 current day is assumed. Alternatively
386                                 the strings
387                                 <literal>yesterday</literal>,
388                                 <literal>today</literal>,
389                                 <literal>tomorrow</literal> are
390                                 understood, which refer to 00:00:00 of
391                                 the day before the current day, the
392                                 current day, or the day after the
393                                 current day, respectively. <literal>now</literal>
394                                 refers to the current time. Finally,
395                                 relative times may be specified,
396                                 prefixed with <literal>-</literal> or
397                                 <literal>+</literal>, referring to
398                                 times before or after the current
399                                 time, respectively.</para></listitem>
400                         </varlistentry>
401
402                         <varlistentry>
403                                 <term><option>-F</option></term>
404                                 <term><option>--field=</option></term>
405
406                                 <listitem><para>Print all possible
407                                 data values the specified field can
408                                 take in all entries of the
409                                 journal.</para></listitem>
410                         </varlistentry>
411
412                         <varlistentry>
413                                 <term><option>-D</option></term>
414                                 <term><option>--directory=</option></term>
415
416                                 <listitem><para>Takes an absolute
417                                 directory path as argument. If
418                                 specified journalctl will operate on the
419                                 specified journal directory instead of
420                                 the default runtime and system journal
421                                 paths.</para></listitem>
422                         </varlistentry>
423
424                         <varlistentry>
425                                 <term><option>--new-id128</option></term>
426
427                                 <listitem><para>Instead of showing
428                                 journal contents generate a new 128
429                                 bit ID suitable for identifying
430                                 messages. This is intended for usage
431                                 by developers who need a new
432                                 identifier for a new message they
433                                 introduce and want to make
434                                 recognizable. Will print the new ID in
435                                 three different formats which can be
436                                 copied into source code or
437                                 similar.</para></listitem>
438                         </varlistentry>
439
440                         <varlistentry>
441                                 <term><option>--header</option></term>
442
443                                 <listitem><para>Instead of showing
444                                 journal contents show internal header
445                                 information of the journal fields
446                                 accessed.</para></listitem>
447                         </varlistentry>
448
449                         <varlistentry>
450                                 <term><option>--disk-usage</option></term>
451
452                                 <listitem><para>Shows the current disk
453                                 usage of all
454                                 journal files.</para></listitem>
455                         </varlistentry>
456
457                         <varlistentry>
458                                 <term><option>--list-catalog</option></term>
459
460                                 <listitem><para>List the contents of
461                                 the message catalog, as table of
462                                 message IDs plus their short
463                                 description strings.</para></listitem>
464                         </varlistentry>
465
466                         <varlistentry>
467                                 <term><option>--update-catalog</option></term>
468
469                                 <listitem><para>Update the message
470                                 catalog index. This command needs to
471                                 be executed each time new catalog
472                                 files are installed, removed or
473                                 updated to rebuild the binary catalog
474                                 index.</para></listitem>
475                         </varlistentry>
476
477                         <varlistentry>
478                                 <term><option>--setup-keys</option></term>
479
480                                 <listitem><para>Instead of showing
481                                 journal contents generate a new key
482                                 pair for Forward Secure Sealing
483                                 (FSS). This will generate a sealing
484                                 key and a verification key. The
485                                 sealing key is stored in the journal
486                                 data directory and shall remain on the
487                                 host. The verification key should be
488                                 stored externally.</para></listitem>
489                         </varlistentry>
490
491                         <varlistentry>
492                                 <term><option>--interval=</option></term>
493
494                                 <listitem><para>Specifies the change
495                                 interval for the sealing key, when
496                                 generating an FSS key pair with
497                                 <option>--setup-keys</option>. Shorter
498                                 intervals increase CPU consumption but
499                                 shorten the time range of
500                                 undetectable journal
501                                 alterations. Defaults to
502                                 15min.</para></listitem>
503                         </varlistentry>
504
505                         <varlistentry>
506                                 <term><option>--verify</option></term>
507
508                                 <listitem><para>Check the journal file
509                                 for internal consistency. If the
510                                 file has been generated with FSS
511                                 enabled, and the FSS verification key
512                                 has been specified with
513                                 <option>--verify-key=</option>
514                                 authenticity of the journal file is
515                                 verified.</para></listitem>
516                         </varlistentry>
517
518                         <varlistentry>
519                                 <term><option>--verify-key=</option></term>
520
521                                 <listitem><para>Specifies the FSS
522                                 verification key to use for the
523                                 <option>--verify</option>
524                                 operation.</para></listitem>
525                         </varlistentry>
526
527                 </variablelist>
528         </refsect1>
529
530         <refsect1>
531                 <title>Exit status</title>
532
533                 <para>On success 0 is returned, a non-zero failure
534                 code otherwise.</para>
535         </refsect1>
536
537         <refsect1>
538                 <title>Environment</title>
539
540                 <variablelist class='environment-variables'>
541                         <varlistentry>
542                                 <term><varname>$SYSTEMD_PAGER</varname></term>
543                                 <listitem><para>Pager to use when
544                                 <option>--no-pager</option> is not given;
545                                 overrides <varname>$PAGER</varname>.  Setting
546                                 this to an empty string or the value
547                                 <literal>cat</literal> is equivalent to passing
548                                 <option>--no-pager</option>.</para></listitem>
549                         </varlistentry>
550                 </variablelist>
551         </refsect1>
552
553         <refsect1>
554                 <title>Examples</title>
555
556                 <para>Without arguments all collected logs are shown
557                 unfiltered:</para>
558
559                 <programlisting>journalctl</programlisting>
560
561                 <para>With one match specified all entries with a field matching the expression are shown:</para>
562
563                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service</programlisting>
564
565                 <para>If two different fields are matched only entries matching both expressions at the same time are shown:</para>
566
567                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097</programlisting>
568
569                 <para>If two matches refer to the same field all entries matching either expression are shown:</para>
570
571                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _SYSTEMD_UNIT=dbus.service</programlisting>
572
573                 <para>If the separator "<literal>+</literal>" is used
574                 two expressions may be combined in a logical OR. The
575                 following will show all messages from the Avahi
576                 service process with the PID 28097 plus all messages
577                 from the D-Bus service (from any of its
578                 processes):</para>
579
580                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service</programlisting>
581
582                 <para>Show all logs generated by the D-Bus executable:</para>
583
584                 <programlisting>journalctl /usr/bin/dbus-daemon</programlisting>
585
586                 <para>Show all logs of the kernel device node <filename>/dev/sda</filename>:</para>
587
588                 <programlisting>journalctl /dev/sda</programlisting>
589
590         </refsect1>
591
592         <refsect1>
593                 <title>See Also</title>
594                 <para>
595                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
596                         <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
597                         <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
598                         <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
599                         <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
600                 </para>
601         </refsect1>
602
603 </refentry>