Skip to main content

Persistent Journald Logging

Introduction

Journald is a system service for collecting and storing log data, introduced with systemd. It tries to make it easier for system administrators to find interesting and relevant information among an ever-increasing amount of log messages.

To avoid excessive wear of the limited flash memory on Toradex modules, the journald data is stored in RAM by default. To debug certain aspects such as unexpected reboots, it is handy to activate persistent journald logging, so the log messages of previous boot cycles can be reviewed.

danger

Please, use this function with caution, as it can decrease the lifespan of your eMMC/NAND due to flash usage for logging.

For more details about each possible parameter to be set for Journald, please consult the Journald Documentation.

Steps to Activate Persistent Logging

info

Make sure you are logged as root before executing the next steps.

  1. Edit the file /etc/systemd/journald.conf, setting up the configuration option Storage=persistent:
# sed -i 's/^#Storage=auto/Storage=persistent/g' /etc/systemd/journald.conf
  1. Edit the file /etc/tmpfiles.d/00-create-volatile.conf, removing the line(s) with /var/volatile/log:
# sed -i '/\/var\/volatile\/log/d' /etc/tmpfiles.d/00-create-volatile.conf
  1. Delete the symbolic link to the log folder:
# rm /var/log

That's it!

Testing the persistent logging

  1. Reboot the module twice:
# reboot
  1. List all boot cycles, and display the detailed messages of the previous (not the current) boot cycle:
# journalctl --list-boots
# journalctl -b -1

Final Considerations

Enabling persistent logs on production is a "good thing", but you shall balance it to avoid memory stress and wear-out. When enabling logging keep the following in mind:

  • Research how to only enable logs and log levels to the minimum. Setting the debug-level as "DEBUG" for development, and then changing it to "ERROR" and above in production may be a good idea.
  • Think about how much of the storage space you will allocate for logging, as well as the logging rotation.
  • Consider using external media for logging, like an SD Card. That will spare the internal flash memory, which is critical since it's where the operating system is.

Search the internet for more information. One example is the article Ultimate Guide to Logging.



Send Feedback!