1

User Image journalctl Jan. 22, 2023, 7:58 p.m.


List boots

journalctl --list-boots


Logs of a previous boot


journalctl -b -1


-b -1 means boot logs of -1 index of boot list


Errors since boot

sudo journalctl -p 3 -xb

-p 3 means priority err

-x provides extra message information

-b means since last boot

priorities

  • 0: emerg
  • 1: alert
  • 2: crit
  • 3: err
  • 4: warning
  • 5: notice
  • 6: info
  • 7: debug


Logs of spesific daemon from a previous time

  1. journalctl -u nginx.service -u php-fpm.service --since today

e.g.:

--since 09:00 --until "1 hour ago"


Display Kernel Logs

  1. journalctl -k



No Pager

  1. journalctl --no-pager

Tail Like

-n and -f works just like in tail


Optimize

Get disk usage

  1. journalctl --disk-usage


Compress


  1. sudo journalctl --vacuum-size=1G

  1. sudo journalctl --vacuum-time=1years





Configure

  1. sudo mkdir -p /var/log/journal # if you planning to make it persistent to see previous bot logs
  2. sudo nano /etc/systemd/journald.conf

[Journal]
#Storage=auto # make persistent if you want to keep logs
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
SystemMaxUse=100M # max size of logs
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=no
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
#ReadKMsg=yes
#Audit=yes


1