As far as I can tell, syslogd in its default configuration throws away all log data on reboot. I have observed this data on Raspbian (Debian Linux-based) and on OPNsense (FreeBSD-based).
From my point of view, this behavior is undesirable. If the system becomes unresponsive and the only way out is to reboot it, or if the system were to reboot on its own for whatever reason, I would want to know what happened just before the reboot. If syslogd clears the log on boot, that is a bummer (and while I wonder what valid use case there would be to do that, it is not the point of my question.)
There is one similar question, How to get syslogd/klogd to append to syslog after reboot instead of overwriting?, but here the issue turned out to be unrelated to syslog.
So, how can I tell syslogd to preserve log data across reboots?
EDIT: Turns out I was already making too many assumptions. The question really should be: what prevents log data from being preserved across reboots? This has been observed when running journalctl
on Raspbian and when viewing the main system log on OPNsense in the web GUI.
syslogd
will write its buffers to the various destinations as soon as it receives the messages. If a system crashes hard between the time the message is received and when it is written to disk (or a networked destination), then you may lose data. Same situation if the system freezes and no processes, including syslogd, are able to do anything. There is certainly no mechanism for syslog to maintain its buffers between reboots./var/log/messages
copied to/var/log/messages.1
or/var/log/messages-20240427
during the reboot? Replacemessages
with whatever filename you are looking for in /var/log. Were the contents of/var/log/messages
available before the reboot?journalctl -b -1 -xe
andjournalctl --list-boots
. Readman journalctl
.