[Answered] Log file persistence, system and openvpn

I tried this post on “General Discussion” but no one responded so I thought I’d try here in “Troubleshooting.”

I am using DietPi on a Raspberry Pi to run a VPN server which I set up with pivpn through dietpi-software. Works pretty well, but there are a few issues such that I’d like to see the system log and openvpn log files. I do have /var/log/openvpn.log and /var/log/syslog present which are filled with the initialization messages at reboot, however at some point shortly after reboot they go to zero (0) bytes so they aren’t storing the information I’d like to see. I recognize they are in temporary file storage, but I don’t know how I can get them to stay around longer.

I expected this would be simple. What am I doing wrong here?


Hi slimbrick,

you need to change your logging system via dietpi-software.
By default logs are cleared every hour (DietPi-Ramlog #1). If you want to stay with RAMlog but store logfiles persistently before cleaning, use DietPi-Ramlog #2
The logfiles will be stored then inside: ~/logfile_storage

Use “None” to disable RAMlog completely, leading to log files being written to disk directly and will not be cleared. Leads to increased disk I/O (SDcard wear) and minor performance decrease, based on how much/in which frequency particular software logs, but releases a bid RAM, as well depending on software logging behaviour.

Choose “Full” to add rsyslog system logging and logrotate. This is from my point of view totally obsolete, since journalctl (systemd-journald daemon) is anyway up, providing full systemlog. journald by default logs to RAM only as well, so will not survive reboot, but you can configure it to store logs persistently inside /var/log/journal/ as well. Simply creating this directory by default already enables persistent system logging: mkdir /var/log/journal
But I am going too much off topic now :rofl:, see above for your questions answer.

Thank you! Exactly what I needed to know, plus a little extra. :sunglasses:

Awesome!!! Great info!

Hello MichaIng Quick question piggybacking on this thread.
Can the /var/log clearing interval be increased?
I’m sending all my logs to a remote online server, so if logs are only stored for 10 minutes, it’s fine by me.

If you anyway send the logs elsewhere. Did you consider to disable/uninstall DietPi-RAMlog and instead mount a remote server network share at /var/log?

Log clearing is done via hourly cron job, see: /etc/cron.hourly/dietpi
You could enable minutely cron jobs via dietpi-cron, set it to 10 minutes, comment the related part of the hourly cron job file and place this in e.g.: /etc/cron.minutely/logclear

But actually the additional effort of minutely running the job is probably not weight out by the reduced log dir size.