Error Codes Wiki

Journalctl Usage Guide — Reading System Logs and Debugging Services

Informationalsystemd

Overview

Complete guide to using journalctl for reading systemd journal logs, filtering by service, time, priority, and exporting logs for debugging Linux issues.

Key Details

  • journalctl reads the systemd journal which collects logs from all systemd services, the kernel, and syslog
  • Logs are stored in binary format in /var/log/journal/ and survive reboots (if configured)
  • Filtering options: by unit (-u), by time (--since, --until), by priority (-p), by boot (-b)
  • Journal can grow large — configure rotation in /etc/systemd/journald.conf
  • journalctl -f provides live log streaming similar to tail -f

Common Causes

  • Service failures generating error logs that need investigation
  • System boot failures leaving diagnostic messages in the journal
  • Disk space consumed by unrotated journal files
  • Missing logs because journald is configured for volatile storage (RAM only)

Steps

  1. 1View all logs: journalctl (press Space to page, q to quit)
  2. 2View specific service: journalctl -u nginx.service -n 100 --no-pager
  3. 3View since time: journalctl --since '2024-01-15 10:00:00' --until '2024-01-15 12:00:00'
  4. 4View only errors: journalctl -p err (priorities: emerg, alert, crit, err, warning, notice, info, debug)
  5. 5View current boot: journalctl -b 0 (previous boot: -b -1)
  6. 6Follow live logs: journalctl -f -u servicename
  7. 7Clean old logs: journalctl --vacuum-size=500M or journalctl --vacuum-time=30d

Tags

journalctlsystemdlogsdebuggingjournal

Related Items

More in Systemd

Frequently Asked Questions

Create the directory: sudo mkdir -p /var/log/journal and sudo systemctl restart systemd-journald. By default, if /var/log/journal/ exists, logs persist.