journald

Follow journal and show only entries with err priority

journalctl -p err -f

Valid priorities are (syslog):

  • 0 emerg (panic / System is unusable)
  • 1 alert (Action must be taken immediately / A condition that should be corrected immediately, such as a corrupted system database)
  • 2 crit (Critical conditions / Hard device errors)
  • 3 err (Error conditions)
  • 4 warning (Warning conditions )
  • 5 notice (Normal but significant conditions / Conditions that are not error conditions, but that may require special handling)
  • 6 info (Informational messages)
  • 7 debug

Assigning stderr priorities

man 3 sd-daemon
fprintf(stderr, SD_NOTICE "Hello World!\n")

reduce journal size

# runtime
sudo journalctl --vacuum-size=50M
 
# permanent
echo SystemMaxUse=50M | sudo tee -a /etc/systemd/journald.conf

read journal from custom location

journalctl --directory=/mnt/var/lib/journal
journalctl --file=/mnt/var/lib/journal/user-1000@*