systemd/Journal - ArchWiki (2024)

systemd has its own logging system called the journal; running a separate logging daemon is not required. To read the log, use journalctl(1).

In Arch Linux, the directory /var/log/journal/ is a part of the systemd package, and the journal (when Storage= is set to auto in /etc/systemd/journald.conf) will write to /var/log/journal/. If that directory is deleted, systemd will not recreate it automatically and instead will write its logs to /run/systemd/journal in a nonpersistent way. However, the directory will be recreated if Storage=persistent is added to journald.conf and systemd-journald.service is restarted (or the system is rebooted).

Systemd journal classifies messages by Priority level and Facility. Logging classification corresponds to classic Syslog protocol (RFC 5424).

Priority level

A syslog severity code (in systemd called priority) is used to mark the importance of a message RFC 5424 6.2.1.

ValueSeverityKeywordDescriptionExamples
0EmergencyemergSystem is unusableSevere Kernel BUG, systemd dumped core.
This level should not be used by applications.
1AlertalertShould be corrected immediatelyVital subsystem goes out of work. Data loss.
kernel: BUG: unable to handle kernel paging request at ffffc90403238ffc.
2CriticalcritCritical conditionsCrashes, coredumps. Like familiar flash:
systemd-coredump[25319]: Process 25310 (plugin-containe) of user 1000 dumped core
Failure in the system primary application, like X11.
3ErrorerrError conditionsNon-fatal error reported:
kernel: usb 1-3: 3:1: cannot get freq at ep 0x84,
systemd[1]: Failed unmounting /var.,
libvirtd[1720]: internal error: Failed to initialize a valid firewall backend
4WarningwarningMay indicate that an error will occur if action is not takenA non-root file system has only 1GB free.
org.freedesktop. Notifications[1860]: (process:5999): Gtk-WARNING **: Locale not supported by C library. Using the fallback 'C' locale
5NoticenoticeEvents that are unusual, but not error conditionssystemd[1]: var.mount: Directory /var to mount over is not empty, mounting anyway,
gcr-prompter[4997]: Gtk: GtkDialog mapped without a transient parent. This is discouraged
6InformationalinfoNormal operational messages that require no actionlvm[585]: 7 logical volume(s) in volume group "archvg" now active
7DebugdebugMessages which may need to be enabled first, only useful for debuggingkdeinit5[1900]: powerdevil: Scheduling inhibition from ":1.14" "firefox" with cookie 13 and reason "screen"

These rules are recommendations, and the priority level of a given error is at the application developer's discretion. It is always possible that the error will be at a higher or lower level than expected.

Facility

A syslog facility code is used to specify the type of program that is logging the message RFC 5424 6.2.1.

Facility codeKeywordDescriptionInfo
0kernKernel messages
1userUser-level messages
2mailMail systemArchaic POSIX still supported and sometimes used (for more mail(1))
3daemonSystem daemonsAll daemons, including systemd and its subsystems
4authSecurity/authorization messagesAlso watch for different facility 10
5syslogMessages generated internally by syslogdFor syslogd implementations (not used by systemd, see facility 3)
6lprLine printer subsystem (archaic subsystem)
7newsNetwork news subsystem (archaic subsystem)
8uucpUUCP subsystem (archaic subsystem)
9Clock daemonsystemd-timesyncd
10authprivSecurity/authorization messagesAlso watch for different facility 4
11ftpFTP daemon
12-NTP subsystem
13-Log audit
14-Log alert
15cronScheduling daemon
16local0Local use 0 (local0)
17local1Local use 1 (local1)
18local2Local use 2 (local2)
19local3Local use 3 (local3)
20local4Local use 4 (local4)
21local5Local use 5 (local5)
22local6Local use 6 (local6)
23local7Local use 7 (local7)

Useful facilities to watch: 0, 1, 3, 4, 9, 10, 15.

Filtering output

journalctl allows for the filtering of output by specific fields. If there are many messages to display, or if the filtering of large time spans has to be done, the output of this command can be extensively delayed.

Examples:

  • Show all messages matching PATTERN:
    # journalctl --grep=PATTERN
  • Show all messages from this boot:
    # journalctl -b
    However, often one is interested in messages not from the current, but from the previous boot (e.g. if an unrecoverable system crash happened). This is possible through optional offset parameter of the -b flag: journalctl -b -0 shows messages from the current boot, journalctl -b -1 from the previous boot, journalctl -b -2 from the second previous and so on – you can see the list of boots with their numbers by using journalctl --list-boots. See journalctl(1) for a full description; the semantics are more powerful than indicated here.
  • Include explanations of log messages from the message catalog where available:
    # journalctl -x
    Note that this feature should not be used when attaching logs to bug reports and support threads, as to limit extraneous output. You can list all known catalog entries by running journalctl --list-catalog.
  • Show all messages from date (and optional time):
    # journalctl --since="2012-10-30 18:17:16"
  • Show all messages since 20 minutes ago:
    # journalctl --since "20 min ago"
  • Follow new messages:
    # journalctl -f
  • Show all messages by a specific executable:
    # journalctl /usr/lib/systemd/systemd
  • Show all messages by a specific process:
    # journalctl _PID=1
  • Show all messages by a specific unit:
    # journalctl -u man-db.service
  • Show all messages from user services by a specific unit:
    $ journalctl --user -u dbus
  • Show kernel ring buffer:
    # journalctl -k
  • Show only error, critical and alert priority messages:
    # journalctl -p err..alert
    You can use numeric log level too, like journalctl -p 3..1. If single number/log level is used, journalctl -p 3, then all higher priority log levels are also included (i.e. 0 to 3 in this case).
  • Show auth.log equivalent by filtering on syslog facility:
    # journalctl SYSLOG_FACILITY=10
  • If the journal directory (by default located under /var/log/journal) contains a large amount of log data then journalctl can take several minutes to filter output. It can be sped up significantly by using --file option to force journalctl to look only into most recent journal:
    # journalctl --file /var/log/journal/*/system.journal -f

See journalctl(1), systemd.journal-fields(7), or Lennart Poettering's blog post for details.

Tip:

  • By default, journalctl truncates lines longer than screen width, but in some cases, it may be better to enable wrapping instead of truncating. This can be controlled by the SYSTEMD_LESS environment variable, which contains options passed to less (the default pager) and defaults to FRSXMK (see less(1) and journalctl(1) for details).
By omitting the S option, the output will be wrapped instead of truncated. For example, start journalctl as follows:
$ SYSTEMD_LESS=FRXMK journalctl
To set this behaviour as default, export the variable from ~/.bashrc or ~/.zshrc.
  • While the journal is stored in a binary format, the content of stored messages is not modified. This means it is viewable with strings, for example for recovery in an environment which does not have systemd installed, e.g.:
    $ strings /mnt/arch/var/log/journal/af4967d77fba44c6b093d0e9862f6ddd/system.journal | grep -i message

Journal size limit

If the journal is persistent (non-volatile), its size limit is set to a default value of 10% of the size of the underlying file system but capped at 4 GiB. For example, with /var/log/journal/ located on a 20 GiB partition, journal data may take up to 2 GiB. On a 50 GiB partition, it would max at 4 GiB. To confirm current limits on your system review systemd-journald unit logs:

# journalctl -b -u systemd-journald

The maximum size of the persistent journal can be controlled by uncommenting and changing the following:

/etc/systemd/journald.conf
SystemMaxUse=50M

It is also possible to use the drop-in snippets configuration override mechanism rather than editing the global configuration file. In this case, place the overrides under the [Journal] header:

/etc/systemd/journald.conf.d/00-journal-size.conf
[Journal]SystemMaxUse=50M

Restart the systemd-journald.service after changing this setting to apply the new limit.

See journald.conf(5) for more info.

Per unit size limit by a journal namespace

Edit the unit file for the service you wish to configure (for example sshd) and add LogNamespace=ssh in the [Service] section.

Then create /etc/systemd/journald@ssh.conf by copying /etc/systemd/journald.conf. After that, edit journald@ssh.conf and adjust SystemMaxUse to your liking.

Restarting the service should automatically start the new journal service systemd-journald@ssh.service. The logs from the namespaced service can be viewed with journalctl --namespace ssh.

See systemd-journald.service(8) § JOURNAL NAMESPACES for details about journal namespaces.

Clean journal files manually

Journal files can be globally removed from /var/log/journal/ using e.g. rm, or can be trimmed according to various criteria using journalctl. For example:

  • Remove archived journal files until the disk space they use falls below 100M:
    # journalctl --vacuum-size=100M
  • Make all journal files contain no data older than 2 weeks.
    # journalctl --vacuum-time=2weeks

Journal files must have been rotated out and made inactive before they can be trimmed by vacuum commands. Rotation of journal files can be done by running journalctl --rotate. The --rotate argument can also be provided alongside one or more vacuum criteria arguments to perform rotation and then trim files in a single command.

See journalctl(1) for more info.

Journald in conjunction with syslog

Compatibility with a classic, non-journald aware syslog implementation can be provided by letting systemd forward all messages via the socket /run/systemd/journal/syslog. To make the syslog daemon work with the journal, it has to bind to this socket instead of /dev/log (official announcement).

The default journald.conf for forwarding to the socket is ForwardToSyslog=no to avoid system overhead, because rsyslog or syslog-ng pull the messages from the journal by itself.

See Syslog-ng#Overview and Syslog-ng#syslog-ng and systemd journal, or rsyslog respectively, for details on configuration.

Forward journald to /dev/tty12

Create a drop-in directory /etc/systemd/journald.conf.d and create a fw-tty12.conf file in it:

/etc/systemd/journald.conf.d/fw-tty12.conf
[Journal]ForwardToConsole=yesTTYPath=/dev/tty12

Then restart systemd-journald.service.

Note: By design, this does not forward kernel ring log messages.

Specify a different journal to view

There may be a need to check the logs of another system that is dead in the water, like booting from a live system to recover a production system. In such case, one can mount the disk in e.g. /mnt, and specify the journal path via -D/--directory, like so:

# journalctl -D /mnt/var/log/journal -e

Journal access as user

By default, a regular user only has access to their own per-user journal. To grant read access for the system journal as a regular user, you can add that user to the systemd-journal user group. Members of the adm and wheel groups are also given read access.

See journalctl(1) § DESCRIPTION and Users and groups#User groups for more information.

systemd/Journal - ArchWiki (2024)

FAQs

Systemd/Journal - ArchWiki? ›

systemd has its own logging system called the journal; running a separate logging daemon is not required. To read the log, use journalctl(1). In Arch Linux, the directory /var/log/journal/ is a part of the systemd package, and the journal (when Storage= is set to auto in /etc/systemd/journald.

What is a systemd journal? ›

systemd-journald is a system service that collects and stores logging data. It creates and maintains structured, indexed journals based on logging information that is received from a variety of sources: Kernel log messages, via kmsg. Simple system log messages, via the libc syslog(3) call.

What is the difference between systemd journal and Rsyslog? ›

The Journal is a component of systemd that is responsible for viewing and management of log files. It can be used in parallel, or in place of a traditional syslog daemon, such as rsyslogd. By default, rsyslogd uses the imjournal module as a default input mode for journal files.

What is the maximum size of the systemd journal? ›

The systemd journal by default retains 4GB of data. In order to increase or decrease that value, set SystemMaxUse and if needed set SystemKeepFree which will be the upper bound of storage that will be kept free on the drive. You set these values in file /etc/systemd/journald. conf under the [Journal] section.

Where is the systemd journal stored? ›

With in-memory journaling, systemd creates its journal files under the /run/log/journal directory. The directory is created if it doesn't exist. With persistent storage, the journal is created under /var/log/journal directory; again, the directory is created by systemd if needed.

What is systemd controversy? ›

Critics argue that systemd is too complex and monolithic, making it harder to troubleshoot. They worry about a single point of failure, as all services are managed by one daemon, and voice concerns about tight integration with the Linux kernel, which could limit portability to other systems.

What is the deal with systemd? ›

systemd is a software suite that provides an array of system components for Linux operating systems. The main aim is to unify service configuration and behavior across Linux distributions. Its primary component is a "system and service manager" — an init system used to bootstrap user space and manage user processes.

What is the name of the systemd journal? ›

The journal itself is a system service managed by systemd . Its full name is systemd-journald. service . It collects and stores logging data by maintaining structured indexed journals based on logging information received from the kernel, user processes, standard input, and system service errors.

How do I find the size of my systemd journal? ›

One of the methods to check the size of the systemd journal is by using the `journalctl` command with the appropriate options. The `journalctl` command provides a wide range of options to filter and display log messages from the journal. To determine the size of the journal, you can use the `–disk-usage` option.

What does systemd do? ›

systemd acts as the init system that brings up and maintains user space services when run as the first process on boot (PID 1). PID 1 is known as init and is the first Linux user-mode process created. It runs until the system shutdown. systemd owns PID 1, and is started directly by the kernel.

How to clear a systemd journal? ›

Clear Systemd Journal Logs in Ubuntu 20.04
  1. Check current disk usage of journal files. sudo journalctl --disk-usage.
  2. Delete journal logs older than 5 days: sudo journalctl --vacuum-time=5days.
  3. Delete log files until the disk space taken falls below 200M: ...
  4. Delete old logs and limit file number to 10:

What command do we use to view the systemd journal? ›

Journalctl is a utility for querying and displaying logs from journald, systemd's logging service. Since journald stores log data in a binary format instead of a plaintext format, journalctl is the standard way of reading log messages processed by journald.

What is systemd journal flush service? ›

The systemd-journal-flush. service asks the journal daemon to flush any log data stored in /run/log/journal into /var/log/journal, if persistent storage is enabled. In case you have (already) huge log files, this will result in slower booting.

Is it safe to delete system journal? ›

Yes, indeed. It's completely fine as long as you don't require the logs for troubleshooting.

What is a journal in Linux? ›

The systemd daemon uses a centralized logging system called a journal, which is managed by the journald daemon. This daemon collects all log entries generated by the Linux kernel or any other systemd unit service regardless of their origin and stores them in a format that is easy to access and manipulate.

References

Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 6243

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.