1<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-logging">
2 <title>Logging</title>
3 <para>
4 System-wide logging is provided by systemd’s
5 <emphasis>journal</emphasis>, which subsumes traditional logging
6 daemons such as syslogd and klogd. Log entries are kept in binary
7 files in <literal>/var/log/journal/</literal>. The command
8 <literal>journalctl</literal> allows you to see the contents of the
9 journal. For example,
10 </para>
11 <programlisting>
12$ journalctl -b
13</programlisting>
14 <para>
15 shows all journal entries since the last reboot. (The output of
16 <literal>journalctl</literal> is piped into <literal>less</literal>
17 by default.) You can use various options and match operators to
18 restrict output to messages of interest. For instance, to get all
19 messages from PostgreSQL:
20 </para>
21 <programlisting>
22$ journalctl -u postgresql.service
23-- Logs begin at Mon, 2013-01-07 13:28:01 CET, end at Tue, 2013-01-08 01:09:57 CET. --
24...
25Jan 07 15:44:14 hagbard postgres[2681]: [2-1] LOG: database system is shut down
26-- Reboot --
27Jan 07 15:45:10 hagbard postgres[2532]: [1-1] LOG: database system was shut down at 2013-01-07 15:44:14 CET
28Jan 07 15:45:13 hagbard postgres[2500]: [1-1] LOG: database system is ready to accept connections
29</programlisting>
30 <para>
31 Or to get all messages since the last reboot that have at least a
32 <quote>critical</quote> severity level:
33 </para>
34 <programlisting>
35$ journalctl -b -p crit
36Dec 17 21:08:06 mandark sudo[3673]: pam_unix(sudo:auth): auth could not identify password for [alice]
37Dec 29 01:30:22 mandark kernel[6131]: [1053513.909444] CPU6: Core temperature above threshold, cpu clock throttled (total events = 1)
38</programlisting>
39 <para>
40 The system journal is readable by root and by users in the
41 <literal>wheel</literal> and <literal>systemd-journal</literal>
42 groups. All users have a private journal that can be read using
43 <literal>journalctl</literal>.
44 </para>
45</chapter>