chiark / gitweb /
journalctl: make the argument to -n optional
[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>--help</option></term>
118                                 <term><option>-h</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>--all</option></term>
140                                 <term><option>-a</option></term>
141
142                                 <listitem><para>Show all fields in
143                                 full, even if they include unprintable
144                                 characters or are very
145                                 long.</para></listitem>
146                         </varlistentry>
147
148                         <varlistentry>
149                                 <term><option>--follow</option></term>
150                                 <term><option>-f</option></term>
151
152                                 <listitem><para>Show only the most recent
153                                 journal entries, and continuously print
154                                 new entries as they are appended to
155                                 the journal.</para></listitem>
156                         </varlistentry>
157
158                         <varlistentry>
159                                 <term><option>--lines=</option></term>
160                                 <term><option>-n</option></term>
161
162                                 <listitem><para>Controls the number of
163                                 journal lines to show, counting from
164                                 the most recent ones. The argument is
165                                 optional, and if specified is a
166                                 positive integer. If not specified and
167                                 in follow mode defaults to 10. If this
168                                 option is not passed and follow mode
169                                 is not enabled, how many lines are
170                                 shown is not
171                                 limited.</para></listitem>
172                         </varlistentry>
173
174                         <varlistentry>
175                                 <term><option>--no-tail</option></term>
176
177                                 <listitem><para>Show all stored output
178                                 lines, even in follow mode. Undoes the
179                                 effect of
180                                 <option>--lines=</option>.</para></listitem>
181                         </varlistentry>
182
183                         <varlistentry>
184                                 <term><option>--output=</option></term>
185                                 <term><option>-o</option></term>
186
187                                 <listitem><para>Controls the
188                                 formatting of the journal entries that
189                                 are shown. Takes one of
190                                 <literal>short</literal>,
191                                 <literal>short-monotonic</literal>,
192                                 <literal>verbose</literal>,
193                                 <literal>export</literal>,
194                                 <literal>json</literal>,
195                                 <literal>json-pretty</literal>,
196                                 <literal>cat</literal>. <literal>short</literal>
197                                 is the default and generates an output
198                                 that is mostly identical to the
199                                 formatting of classic syslog log
200                                 files, showing one line per journal
201                                 entry. <literal>short-monotonic</literal>
202                                 is very similar but shows monotonic
203                                 timestamps instead of wallclock
204                                 timestamps. <literal>verbose</literal>
205                                 shows the full structured entry items
206                                 with all
207                                 fields. <literal>export</literal>
208                                 serializes the journal into a binary
209                                 (but mostly text-based) stream
210                                 suitable for backups and network
211                                 transfer (see <ulink
212                                 url="http://www.freedesktop.org/wiki/Software/systemd/export">Journal
213                                 Export Format</ulink> for more
214                                 information). <literal>json</literal>
215                                 formats entries as JSON data
216                                 structures, one per
217                                 line. <literal>json-pretty</literal>
218                                 also formats entries as JSON data
219                                 structures, but formats them in
220                                 multiple lines in order to make them
221                                 more readable for
222                                 humans. <literal>cat</literal>
223                                 generates a very terse output only
224                                 showing the actual message of each
225                                 journal entry with no meta data, not
226                                 even a timestamp.</para></listitem>
227                         </varlistentry>
228
229                         <varlistentry>
230                                 <term><option>--quiet</option></term>
231                                 <term><option>-q</option></term>
232
233                                 <listitem><para>Suppresses any warning
234                                 message regarding inaccessible system
235                                 journals when run as normal
236                                 user.</para></listitem>
237                         </varlistentry>
238
239                         <varlistentry>
240                                 <term><option>--merge</option></term>
241                                 <term><option>-m</option></term>
242
243                                 <listitem><para>Show entries
244                                 interleaved from all available
245                                 journals, including remote
246                                 ones.</para></listitem>
247                         </varlistentry>
248
249                         <varlistentry>
250                                 <term><option>--this-boot</option></term>
251                                 <term><option>-b</option></term>
252
253                                 <listitem><para>Show data only from
254                                 current boot.</para></listitem>
255                         </varlistentry>
256
257                         <varlistentry>
258                                 <term><option>--directory=</option></term>
259                                 <term><option>-D</option></term>
260
261                                 <listitem><para>Takes an absolute
262                                 directory path as argument. If
263                                 specified journalctl will operate on the
264                                 specified journal directory instead of
265                                 the default runtime and system journal
266                                 paths.</para></listitem>
267                         </varlistentry>
268
269                         <varlistentry>
270                                 <term><option>-p</option></term>
271                                 <term><option>--priority=</option></term>
272
273                                 <listitem><para>Filter output by
274                                 message priorities or priority
275                                 ranges. Takes either a single numeric
276                                 or textual log level (i.e. between
277                                 0/<literal>emerg</literal> and
278                                 7/<literal>debug</literal>), or a
279                                 range of numeric/text log levels in
280                                 the form FROM..TO. The log levels are
281                                 the usual syslog log levels as
282                                 documented in
283                                 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
284                                 i.e. <literal>emerg</literal> (0),
285                                 <literal>alert</literal> (1),
286                                 <literal>crit</literal> (2),
287                                 <literal>err</literal> (3),
288                                 <literal>warning</literal> (4),
289                                 <literal>notice</literal> (5),
290                                 <literal>info</literal> (6),
291                                 <literal>debug</literal> (7). If a
292                                 single log level is specified all
293                                 messages with this log level or a
294                                 lower (hence more important) log level
295                                 are shown. If a range is specified all
296                                 messages within the range are shown,
297                                 including both the start and the end
298                                 value of the range.</para></listitem>
299                         </varlistentry>
300
301                         <varlistentry>
302                                 <term><option>--new-id128</option></term>
303
304                                 <listitem><para>Instead of showing
305                                 journal contents generate a new 128
306                                 bit ID suitable for identifying
307                                 messages. This is intended for usage
308                                 by developers who need a new
309                                 identifier for a new message they
310                                 introduce and want to make
311                                 recognizable. Will print the new ID in
312                                 three different formats which can be
313                                 copied into source code or
314                                 similar.</para></listitem>
315                         </varlistentry>
316
317                         <varlistentry>
318                                 <term><option>--header</option></term>
319
320                                 <listitem><para>Instead of showing
321                                 journal contents show internal header
322                                 information of the journal fields
323                                 accessed.</para></listitem>
324                         </varlistentry>
325
326                         <varlistentry>
327                                 <term><option>--disk-usage</option></term>
328
329                                 <listitem><para>Shows the current disk
330                                 usage of all
331                                 journal files.</para></listitem>
332                         </varlistentry>
333
334                         <varlistentry>
335                                 <term><option>--setup-keys</option></term>
336
337                                 <listitem><para>Instead of showing
338                                 journal contents generate a new key
339                                 pair for Forward Secure Sealing
340                                 (FSS). This will generate a sealing
341                                 key and a verification key. The
342                                 sealing key is stored in the journal
343                                 data directory and shall remain on the
344                                 host. The verification key should be
345                                 stored externally.</para></listitem>
346                         </varlistentry>
347
348                         <varlistentry>
349                                 <term><option>--interval=</option></term>
350
351                                 <listitem><para>Specifies the change
352                                 interval for the sealing key, when
353                                 generating an FSS key pair with
354                                 <option>--setup-keys</option>. Shorter
355                                 intervals increase CPU consumption but
356                                 shorten the time range of
357                                 undetectable journal
358                                 alterations. Defaults to
359                                 15min.</para></listitem>
360                         </varlistentry>
361
362                         <varlistentry>
363                                 <term><option>--verify</option></term>
364
365                                 <listitem><para>Check the journal file
366                                 for internal consistency. If the
367                                 file has been generated with FSS
368                                 enabled, and the FSS verification key
369                                 has been specified with
370                                 <option>--verify-key=</option>
371                                 authenticity of the journal file is
372                                 verified.</para></listitem>
373                         </varlistentry>
374
375                         <varlistentry>
376                                 <term><option>--verify-key=</option></term>
377
378                                 <listitem><para>Specifies the FSS
379                                 verification key to use for the
380                                 <option>--verify</option>
381                                 operation.</para></listitem>
382                         </varlistentry>
383
384                 </variablelist>
385         </refsect1>
386
387         <refsect1>
388                 <title>Exit status</title>
389
390                 <para>On success 0 is returned, a non-zero failure
391                 code otherwise.</para>
392         </refsect1>
393
394         <refsect1>
395                 <title>Environment</title>
396
397                 <variablelist>
398                         <varlistentry>
399                                 <term><varname>$SYSTEMD_PAGER</varname></term>
400                                 <listitem><para>Pager to use when
401                                 <option>--no-pager</option> is not given;
402                                 overrides <varname>$PAGER</varname>.  Setting
403                                 this to an empty string or the value
404                                 <literal>cat</literal> is equivalent to passing
405                                 <option>--no-pager</option>.</para></listitem>
406                         </varlistentry>
407                 </variablelist>
408         </refsect1>
409
410         <refsect1>
411                 <title>Examples</title>
412
413                 <para>Without arguments all collected logs are shown
414                 unfiltered:</para>
415
416                 <programlisting>journalctl</programlisting>
417
418                 <para>With one match specified all entries with a field matching the expression are shown:</para>
419
420                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service</programlisting>
421
422                 <para>If two different fields are matched only entries matching both expressions at the same time are shown:</para>
423
424                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097</programlisting>
425
426                 <para>If two matches refer to the same field all entries matching either expression are shown:</para>
427
428                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _SYSTEMD_UNIT=dbus.service</programlisting>
429
430                 <para>If the separator "<literal>+</literal>" is used
431                 two expressions may be combined in a logical OR. The
432                 following will show all messages from the Avahi
433                 service process with the PID 28097 plus all messages
434                 from the D-Bus service (from any of its
435                 processes):</para>
436
437                 <programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service</programlisting>
438
439                 <para>Show all logs generated by the D-Bus executable:</para>
440
441                 <programlisting>journalctl /usr/bin/dbus-daemon</programlisting>
442
443                 <para>Show all logs of the kernel device node <filename>/dev/sda</filename>:</para>
444
445                 <programlisting>journalctl /dev/sda</programlisting>
446
447         </refsect1>
448
449         <refsect1>
450                 <title>See Also</title>
451                 <para>
452                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
453                         <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
454                         <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
455                         <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
456                         <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
457                 </para>
458         </refsect1>
459
460 </refentry>