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?
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.
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
name-of-share can be chosen to freely
edit /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg: edit the line
log4j.appender.out.file=/mnt/shares/name-of-share/openhab.log
Step 3 can be repeated for every logfile you desire to write to the network drive
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?
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)…
RPi 4
Raspbian initial load, followed by Openhabian install
8G USB thumbdrive, exfat
I just tried your above recommendation, after copying my existing event and openhab logs over for appending purpose, and setting the USB thumbdrive directory permissions to rw for owner, group and others. The OPENHAB_LOGDIR now points to a directory on the thumbdrive;
logdir=/media/pi/EMTEC/openhablogs
When I check the status (systemctl status openhab2.service) I’m getting the following;
Jan 19 14:52:24 raspberrypi karaf[17392]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Null object returned for RollingRandomAccessFile in Appenders. Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Jan 19 14:52:24 raspberrypi karaf[17392]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate appender “LOGFILE” for logger config “root” Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
Jan 19 14:52:24 raspberrypi karaf[17392]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate appender “AUDIT” for logger config “org.apache.karaf.jaas.modules.audit” Ignored FQCN: org.apache.logging.log4j.spi.Abst
Jan 19 14:52:24 raspberrypi karaf[17392]: org.ops4j.pax.logging.pax-logging-api [log4j2] ERROR : Unable to locate appender “EVENT” for logger config “smarthome.event” Ignored FQCN: org.apache.logging.log4j.spi.AbstractLogger
SSD drive is installed and logging is working perfectly, thanks to your tips. I created a logfile directory with a new group that includes users pi and openhab. It’s working splendidly after multiple reboots. Much appreciated!
I also updated my frontail config file to point to the new logging directory on my SSD (for anyone following this thread, for Raspbian [and likely any Debian] it is at /etc/systemd/system/frontail.service)
It’s a nice feature of OH2 - especially for embedded systems like Raspberry - that you can set the log dir to an external SD/USB/SSD/… It keps your SD-card clean and working.
I just found out that there is even a better way to change the path.
After updating to the new version of OH (2.5.4-1) I had to redo the changes. The currently used version of systemd allows an easy overriding of configs without having to change the original file.