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