1.5 KiB
1.5 KiB
LPIC-1 108.2: System logging
logger and the journal, an rsyslog rule, a persistent journal, and a
logrotate rule.
Before you start
The lab makes the journal non-persistent: if /var/log/journal exists, it
moves it to /var/log/journal.le-lab (reset puts it back), so the journal
lives in /run and is lost at every reboot. Task 3 needs a reboot; do task
1 again afterwards if its message was lost with it.
Tasks
- Send a message with
logger -t test -p user.warningand find it withjournalctl -t testand, if rsyslog is installed, in/var/log. - Install rsyslog if needed, add a rule sending
local3.*to/var/log/local3.log, restart it, and test withlogger -p local3.info. - Check whether the journal is persistent with
ls /var/log/journal. Make it persistent, reboot, and read the previous boot withjournalctl -b -1. - As root, write a logrotate rule
/etc/logrotate.d/lrtestfor/var/log/lrtest/test.log, fill the log, and runlogrotate -dand thenlogrotate -fon the rule, so that the log is rotated.
Hints
journalctl -t test -p warning;grep test /var/log/syslogor/var/log/messages.- A file in
/etc/rsyslog.d/ending in.conf;rsyslogd -N1checks the configuration. Storage=persistentin/etc/systemd/journald.conf(or a drop-in), or create/var/log/journal;journalctl --list-boots.mkdir /var/log/lrtest; a block withrotate,sizeordaily,compress,missingok;logrotate -d /etc/logrotate.d/lrtest.