Im using DietPi-RAMlog #2 to save and preserve logs to /root/logfile_storage folder.
How can I view that saved logs of the system?
I had to reboot the raspberry zero and wanted to see my last logs before the reboot and I see only these files in that folder:
alternatives.log btmp dpkg.log lastlog wtmp
Journalctl only shows logs since the last boot of system.
I tried to specify log directory to /root/logfile_storage for journalctl but it said no log files over there.
I couldnt find any human readable text based log files either.
The dietpi settings of logging system says: DietPi-RAMlog #2: Same as #1, with the added feature of appending logfile contents to disk at /root/logfile_storage, before being cleared.
But I found no previously saved logs of the system that journalctl used to show…
I guess @MichaIng could explain it best.
Yes that is expected. These are all plain text log files written to
/var/log. System logs are kept as binary format in memory. There are two options:
rsyslogto have additional system log plain text files created. When doing so in combination with RAM log enabled, take care that the size is sufficient, respectively that the system log files do no grow too fast:
- Make journal system logs boot persistent. They are kept in RAM by default, more precisely in
/run/log/journal, but you can have them created in
/var/log/journalas well, so
journalctlshows logs from previous boot sessions. But this doesn’t work well in combination with RAM log, I’d say, because the size of these files can be quite large, and as I’m not sure whether the
dietpi-ramlog.servicecan restore them sufficiently early, before
systemd-journald.service, so that the latter starts writing directly to the existing files instead of creating a new dir and likely failing when
dietpi-ramlog.serviceattempts to overwrite them with the old files, or so. A second problem is that DietPi-RAMlog appends existing log file content to the stored files on disk, and I guess this does not work for the binary journal log files, but just breaks them.
So instead of trial&error with option 2, I think it would then be better to disable RAM log and enable disk journal.
Actually I never checked whether systemd-journald has an own feature to regularly store logs to disk. Would be quite handy.