[Answered] Log file persistence, system and openvpn

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
slimbrick
Posts: 6
Joined: Fri Dec 29, 2017 7:07 pm

[Answered] Log file persistence, system and openvpn

Post by slimbrick »

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?

Thanks.
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: Log file persistence, system and openvpn

Post by MichaIng »

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 :lol:, see above for your questions answer.
slimbrick
Posts: 6
Joined: Fri Dec 29, 2017 7:07 pm

Re: Log file persistence, system and openvpn

Post by slimbrick »

Thank you! Exactly what I needed to know, plus a little extra. 8)
User avatar
WarHawk
Posts: 606
Joined: Thu Jul 20, 2017 8:55 am

Re: [Answered] Log file persistence, system and openvpn

Post by WarHawk »

Awesome!!! Great info!
sibero80
Posts: 3
Joined: Sat Mar 30, 2019 5:06 am

Re: [Answered] Log file persistence, system and openvpn

Post by sibero80 »

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.
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: [Answered] Log file persistence, system and openvpn

Post by MichaIng »

@sibero80
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.
Post Reply