Change default location of logfiles (openhab.log and events.log)

Tags: #<Tag:0x00007fd30f4afee0> #<Tag:0x00007fd30f4afda0>

(Duco Bouter) #1

Hi there,

I’ve read a couple of hours on this subject but unfortunately found no working solution. I want to change the location where Openhab2 (Openhabian) writes logfiles.

Can someone push me and hopefully others in the right direction?


(Rich Koshak) #2

Take this as a template to edit /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg to change the path where the logs are saved.

(Duco Bouter) #3

I’ll try that again. It did try to change the “log4j.appender.event.file=${openhab.logdir}/events.log” to “log4j.appender.event.file=/mnt/shares/RemoteOpenhab/events.log”, whre RemoteOpenhab is some networkshare on a nas. But nothing happend.

I now realise I didn’t set the mount to writable… Will test again.

(Duco Bouter) #4

Tested and working!

For those who want to do this:

  1. Edit /etc/fstab: add a line: (this adds the network drive on boot as a writable folder)
    //ip-of-nas/share-on-nas /mnt/shares/name-of-share cifs username=username,password=password,file_mode=0777,dir_mode=0777 0 0

  2. name-of-share can be chosen to freely

  3. edit /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg: edit the line

  4. Step 3 can be repeated for every logfile you desire to write to the network drive

(Marcus) #5

Good morning

Is anything about this changed since i was trying to edit as posted but to another local folder at first to validate function before going to nfs share. Changed booth event and out file to /media/log but what about file pattern. Could you set the variable logdir somplace else instead?

(Scott Rushworth) #6

Here is an example of what I use fro zwave logging. The log file is moved to another directory and the file name pattern is changed (much better for grepping the log files, as the results will be sorted chronologically)…

log4j2.appender.ZWave.fileName = /opt/openhab2/userdata/logs/zwave/zwave.log
log4j2.appender.ZWave.filePattern = /opt/openhab2/userdata/logs/zwave/zwave.log.%d{yyyyMMddHHmmss}