journalctl & Log Management
journalctl filtering, persistent logs, vacuum, priority levels, and journald.conf tuning.
Overview
journald is systemd's logging daemon. It collects log entries from the kernel, systemd units, and any process that writes to stdout/stderr or calls syslog(). Unlike traditional text-based syslog, journald stores logs in a structured binary format that supports efficient filtering by time, unit, priority, PID, UID, and arbitrary fields. journalctl is the tool that reads them back.
Storage Locations
Journald keeps its files in one of two places, and the choice decides whether your logs survive a reboot. By default it writes to /var/log/journal/ if that directory exists, and to /run/log/journal/ if it does not.
- Volatile storage: /run/log/journal/, the default on many distros. It is lost on reboot. Only kernel crash logs can outlast it: where the EFI pstore or pmsg is available, the kernel saves its last messages there when it crashes, so they can be read after the next boot.
- Persistent storage: /var/log/journal/, which survives reboots. Enable it by setting Storage=persistent in /etc/systemd/journald.conf or by creating the directory: mkdir -p /var/log/journal && systemd-tmpfiles --create --prefix /var/log/journal.
Key concepts
- journald
- journalctl -u
- -p priority
- --vacuum-size / --vacuum-time
- Storage=persistent
- -o json
Interview questions
- How do you make systemd journal logs persist across reboots and manage their disk usage?
- Show common journalctl query patterns for production incident investigation.
Sign up free to read the full topic
More Linux topics
Start free on Cariara · Coding problems · System design studio