Enable Persistent Logging for Systemd/Journalctl

This article provides a guide to enable persistent logging for systemd and journalctl on your Linux VPS or Dedicated Servers.

Why Should We Enable Persistent Logging for Systemd?

Natively, the systemd logs are logged to /run/log/journal by default, which does not support persistent logging. On the one hand, it's nice not to have huge log files eating up all your server storage. On the other hand, these logs definitely won't help if there is any ongoing or recurring issues. The reason for this is that this configuration and storage are rotated frequently, such that the events surrounding an even once-daily server issue wouldn't still be logged by the time of recurrence.

And while, persistent logging of all systemd systems wouldn't be right for everyone, it's definitely nice to know the option exist. So, let's take a look at what this process will be if we wanted to enable persistent storage for systemd/journallctl

Enable Persistent Logging for Systemd/Journalctl

To enable persistent logging for systemd journalctl, follow the steps provided below:

  1. Login via SSH as root (or root-equivalent) user.
  2. Run the following commands to setup a suitable storage:
    sudo mkdir -p /var/log/journal
    sudo systemd-tmpfiles --create --prefix /var/log/journal
    sudo systemctl restart systemd-journald

Now, the logs will persist beyond reboots, which will make it easier to troubleshoot any ongoing issues.

Log Rotation and Compression

With persistent logs, now we will need to manage the log rotation and storage use using the built-in compression and rotation system. These settings are configured from /etc/systemd/journald.conf.

Conclusion

You now know how to enable persistent logging for system/journalctl on Linux VPS or dedicated server.

  • systemd, journalctl, system logs, logs
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Forcefully Delete an IP Address from SolusVM

If at any point you find you have an orphaned ipaddress, you can delete it by running the...

Do You Offer a Hardware Firewall Solution?

Yes, we have a very limited selection of hardware firewalls available. We appreciate the specific...

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...