|
23 | 23 | < meta name= "maintainer" content= "[email protected]" its:translate= "no"/> |
24 | 24 | <abstract><!-- can be changed via merge in the assembly --> |
25 | 25 | <para> |
26 | | - Journal is a centralization and unification of logs from all sources, and it stores events in structured manner which in turn helps identifying errors and in crash recovery. |
| 26 | + Journal is a centralization and unification of logs from all sources, and it stores events in structured manner which in turn helps identifying errors and in crash recovery. |
27 | 27 | </para> |
28 | 28 | </abstract> |
29 | 29 | </info> |
|
33 | 33 | By default, <literal>journald</literal> stores the collected data in the volatile memory in |
34 | 34 | <filename>/run/log/journal</filename>, so after reboot the data is lost. |
35 | 35 | </para> |
| 36 | + <para> |
| 37 | + If <literal>systemd-journald</literal> is configured to store the logs in a persistent |
| 38 | + manner, you can find the journal in <filename>/var/log/journal</filename>. Ensure that the |
| 39 | + directoy exists: |
| 40 | + </para> |
| 41 | + <procedure> |
| 42 | + <step> |
| 43 | + <para> |
| 44 | + Check if the directory exist: |
| 45 | + </para> |
| 46 | + <screen>&prompt.sudo;<command>ls /var/log</command> |
| 47 | +... |
| 48 | +journal |
| 49 | +... |
| 50 | + |
| 51 | + </screen> |
| 52 | + |
| 53 | + </step> |
| 54 | + <step> |
| 55 | + <para>If the <filename>/var/log/journal</filename> directory does not exist, create |
| 56 | + it:</para> |
| 57 | + <screen>&prompt.sudo;<command>mkdir /var/log/journal</command> |
| 58 | + </screen> |
| 59 | + </step> |
| 60 | + <step> |
| 61 | + <para> |
| 62 | + Set correct ownership and access perimissions: |
| 63 | + </para> |
| 64 | + <screen>&prompt.sudo; systemd-tmpfiles --create --prefix=/var/log/journal</screen> |
| 65 | + </step> |
| 66 | + <step performance="optional"> |
| 67 | + <para> |
| 68 | + To flush the data from RAM to the directory: |
| 69 | + </para> |
| 70 | + <screen>&prompt.sudo; <command>journalctl --flush</command></screen> |
| 71 | + </step> |
| 72 | + </procedure> |
| 73 | + <para>For details about |
| 74 | + the service configuration, refer to <xref linkend="journal-configure-journald"/>. |
| 75 | + </para> |
36 | 76 | </section> |
37 | 77 | <section xml:id="journal-what-it-is-structure"> |
38 | | - <title>The structure of the journal</title> |
| 78 | + <title>The journal logs structure</title> |
39 | 79 | <para> |
40 | | - A paragraph of text, answering the question above and explaining the |
41 | | - mechanism behind foo bar. |
| 80 | + The logs are stored in binary format across several files. To view the structure of a log |
| 81 | + entry, proceed as follows: |
42 | 82 | </para> |
| 83 | + <screen>&prompt.sudo; <command>journalctl -n 1 -o verbose</command> |
43 | 84 |
|
| 85 | + Fri 2025-12-05 10:52:53.284321 CET [s=5b7ae2e926794210bf832d014f5f560a;i=d49752> |
| 86 | + _UID=1000 |
| 87 | + _AUDIT_SESSION=3 |
| 88 | + _AUDIT_LOGINUID=1000 |
| 89 | + _SYSTEMD_OWNER_UID=1000 |
| 90 | + |
| 91 | + _SYSTEMD_SLICE=user-1000.slice |
| 92 | + _MACHINE_ID=d3489468c8534c5d81a2860cf9a2a20e |
| 93 | + _RUNTIME_SCOPE=system |
| 94 | + _SELINUX_CONTEXT=unconfined |
| 95 | + PRIORITY=6 |
| 96 | + _TRANSPORT=syslog |
| 97 | + _BOOT_ID=d095069bd59b4bc4bf67c8c71999243b |
| 98 | + SYSLOG_IDENTIFIER=sudo |
| 99 | + SYSLOG_TIMESTAMP=Dec 5 10:52:53 |
| 100 | + _PID=25806 |
| 101 | + _COMM=sudo |
| 102 | + _EXE=/usr/bin/sudo |
| 103 | + _CMDLINE=sudo journalctl -n 1 -o verbose |
| 104 | + |
| 105 | + ... |
| 106 | + </screen> |
| 107 | + <para>The log entry is a data structure containing the log message and metadata fields:</para> |
| 108 | + <variablelist> |
| 109 | + <varlistentry> |
| 110 | + <term>Timestamp</term> |
| 111 | + <listitem> |
| 112 | + <para> |
| 113 | +The exact time the event occured |
| 114 | + </para> |
| 115 | + </listitem> |
| 116 | + </varlistentry> |
| 117 | + <varlistentry> |
| 118 | + <term>Source Fields</term> |
| 119 | + <listitem> |
| 120 | + |
| 121 | + <itemizedlist> |
| 122 | + <listitem><para><literal>_PID</literal>: process ID of the sender</para></listitem> |
| 123 | + <listitem><para><literal>_UID/_GID</literal>: User/Group ID of the sender</para></listitem> |
| 124 | + <listitem><para><literal>_EXE</literal>: path to the executable</para></listitem> |
| 125 | + <listitem><para><literal>_COMM</literal>: name of the executable</para></listitem> |
| 126 | +</itemizedlist> |
| 127 | + </listitem> |
| 128 | + </varlistentry> |
| 129 | + <varlistentry> |
| 130 | + <term>System Fields</term> |
| 131 | + <listitem> |
| 132 | + <itemizedlist> |
| 133 | + <listitem><para><literal>_SYSTEMD_UNIT</literal>: The systemd unit (service) that generated the |
| 134 | + log (for example, <literal>sshd.service</literal>)</para></listitem> |
| 135 | + <listitem><para><literal>_BOOT_ID</literal>: A unique identifier for the specific system boot session</para></listitem> |
| 136 | +</itemizedlist> |
| 137 | + </listitem> |
| 138 | + </varlistentry> |
| 139 | + <varlistentry> |
| 140 | + <term>Kernel Fields</term> |
| 141 | + <listitem><para><literal>_TRANSPORT</literal>: How the message was logged (e.g., kernel, syslog, stdout).</para></listitem> |
| 142 | + </varlistentry> |
| 143 | + <varlistentry> |
| 144 | + <term>Priority level</term> |
| 145 | + <listitem> |
| 146 | + <para>A numeric value indicating the severity of the message (0=emerg, 7=debug)</para> |
| 147 | + </listitem> |
| 148 | + </varlistentry> |
| 149 | + </variablelist> |
44 | 150 | </section> |
45 | 151 | </topic> |
0 commit comments