Skip to content
Calin Crisan edited this page May 5, 2022 · 6 revisions

Log Directory

All the components are configured so that they put their log files in /var/log. It is in fact a symbolic link to /data/log, a directory that is created at first boot. This way, logs are persisted on the only writable partition and are preserved across firmware updates.

Log Rotation

The cron daemon runs logrotate every day at 3:14, using the /etc/logrotate.conf configuration file.

All files in /var/log having a .log extension will be compressed and rotated as soon as they reach a size of 10MB. No more than 9 rotated versions will be kept for each log file.

Logs In RAM

Logs are very useful for identifying what went wrong and that's why, in most cases, we want logs to be persisted (i.e. written to the SD card). However there are applications where we simply don't care that much about logs and we prefer preventing any possible writing to the SD card.

To configure an existing system to write its logs to RAM, you simply need to transform the /data/log directory into symbolic link pointing to /tmp, which is a temporary filesystem mounted in RAM:

mv /data/log /data/log.bak
ln -s /tmp /data/log
reboot

After reboot, you can optionally remove the old logs directory:

rm -r /data/log.bak

To build an OS that has its log directory in RAM by default, just edit the postscript.sh file and change ln -s /data/log $TARGET/var/log into ln -s /tmp $TARGET/var/log.

Syslog

The syslog daemon provided by busybox is automatically started at boot by S05syslog. It uses the /etc/syslog.conf configuration file and logs to /var/log/messages.

Common Log Files

boot.log

The boot log (the output from the init scripts) is written (appended) to /var/log/boot.log. This is done by the main script that handles the boot process, /etc/init.d/rcS.

dmesg.log

The kernel log (dmesg) is written (appended) to /var/log/dmesg.log. This is done by the /etc/init.d/S05syslog init script, using dmesg -w.

messages

The /var/log/messages file is the output of the syslog daemon. This can be changed in /etc/syslog.conf.

Clone this wiki locally