Cleanup Log-Files

I’m a big fan of a clean system and that’s why I delete from time to time all the log files :slight_smile:

openHAB creates the new log files only during the boot process. Does someone know if there is a process or command available (e.g. console) to force that without a reboot?

I also tried this:
> /var/log/openhab2/openhab.log

This command works to empty the file, but the system is in appending mode, remembers the line and creates a lot of empty lines (nulls) as soon as the next entry is written.

you should not do that manually - let the system do it for you. Have a look at the logrotate command.

man logrotate

See also:

You can define when ( day, file size ) a log should be rotated ( this means a new file is to be created ) and how many files to keep to be able to analyze problems from the past.
Older files also will be compressed in case they should be kept.

1 Like

openhab has its builtin log management which will interfere with logrotate.

Read up on log4j2 and configure in /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg.


As Markus mentioned above. :+1:

Here is a topic that may help.