Member-only story
A Comprehensive Guide to Using journalctl with systemd for Effective Log Management
journalctl
is a tool for querying and displaying logs collected by the systemd logging system (the systemd-journald
service). It includes log rotation (logrotate) functionality and offers rich filtering capabilities, enabling users to view logs from all systemd service units, which helps in quickly locating log information.
The systemd-journald
daemon is a system service that aggregates and stores log data. Entries in the Journal can come from multiple sources, including server messages, user-level program messages, kernel messages collected by syslogd, and system service information like generated error messages or boot-time information.
systemd-journald System Logging Component
- Daemon:
systemd-journald
- Configuration File:
/etc/systemd/journald.conf
- Log Search Utility:
journalctl
By default, journald will overwrite its logs upon each reboot. rsyslog
retrieves logs by loading the journal driver and saves them to a disk file (/var/log/messages
).
To enable persistent log storage in journald, modify the “Storage=auto” parameter in the journald.conf
file to "Storage=persistent" and restart the systemd-journald
service.
sed -i 's/Storage=auto/Storage=persistent/g' /etc/systemd/journald.conf
systemctl restart systemd-journald