OH 3 no longer writes in "event.log"

Ah, this is useful! Maybe I can finally stop going into Karaf only to do “log:tail”! Can you combine multiple filters with AND/OR?

A suggestion (@ysc, reading this?): The icing on the cake here would be away to choose between some nice predefined filters (like */statechanged) and also to save filters of your own!

They are OR I think but have played much with them to confirm.

I was able to confirm that it’s OR.

So, for example, to see all statechanged events for all Item but also all state updates but just for Item Foo use the following filter:

*/statechanged,*/Foo/state

I’ve now deleted my log4j.xml and recreated it with the content of your file, updated to Buils #2078, nothing works. Anyway, I’ll be able to work with the developer sidebar until the release of OH 3 and then I’ll install OH from scratch anyway. Thanks for your effort.

i have the same issue using OH3.0.0 - Release Build
/var/lib/openhab/etc/log4j2.xml is fine with "openhab.event… "
In karaf with log:tail, i see events but there are no log files created at /var/log/openhab.

has somebody seen the same?

I did the update from RC1 RC2 to Final and had the same.
apt remove / install or reinstall did not help

apt remove -purge openhab
apt install openhab
and then a clean start got it now working for me - did not check yet to restore the config backup

1 Like

found the issue, the folder permissions being on root cause that the logfiles were not created. No idea how that happened.
i had


using sudo chown openhab:openhab openhab
to change the directory permission with a reboot resolved the issue. i have now logs files in /var/log/openhab

There’s also a etc/org.ops4j.pax.logging.cfg file that should only contain the line:

org.ops4j.pax.logging.log4j2.config.file=${karaf.etc}/log4j2.xml

If you have rejected during the upgrade the suggested changes to that file by the package manager, then you may have also broken your logging configuration.

1 Like

Hi Wouter, thanks for advise. Yes, that files is like expected
image

Pretty sure, that using OH3 from RC1 RC2 to OH3.0.0, the folder permission got messed up.

Yes your issue is definitely a permissions problem. I added my comment for completeness. :wink:

1 Like

Hi.
I just discovered that I haven’t got anything in my openhab.log since upgrading to final 3.0 (from RC1 where it worked fine). Writing to events.log works fine but openhab.log is completely empty. I have checked the stuff suggested above (org.ops4j.pax.logging.cfg, log4j2.xml, permissions on /var/log/openhab) and everything seems correct.

Or wait… This might be a problem with log rotation… I just realized that time stamps in events.log starts today at midnight, nothing before that. Like both events.log and openhab.log were scratched at midnight, and simply nothing have been logged to openhab.log since then. Is this normal? I’d really like the ability to check more than 24 hours back in my logs…

It’s hard to say. OH3’s openHAB log is really sparse. If you don’t have Rules writing to it I can imagine it could go a day or more without an entry on its own. But if you have Rules that should be logging then there might be some sort of problem.

Sorry, my question was too vague. I didn’t wonder wether it was normal with nothing written in the log during a day, what I wonder if it’s normal for OH rotating the logs. It has never done that before, I’ve always had my entire log in a single file. It seems like it’s trying to rotate the log and somehow failing in the process.

edit: Ok, scratch that. It seems today the rotation suddenly seems to started working, I have now got files named openhab.log.1 and events.log.1. Strange things happen…

After an openHAB restart the log files are rotating. And if you are on a default setup the file size for rotating is in your log4j2.xml:

		<!-- Rolling file appender -->
		<RollingFile fileName="${sys:openhab.logdir}/openhab.log" filePattern="${sys:openhab.logdir}/openhab.log.%i" name="LOGFILE">
			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
			<Policies>
				<OnStartupTriggeringPolicy/>
				<SizeBasedTriggeringPolicy size="16 MB"/>
			</Policies>
		</RollingFile>

So for the openhab.log the file size is 16MB, after that it is rotating.

Ah, that’s the difference! I don’t think my log files ever reached 16 MB and in OH 2.x they weren’t rotated upon OH restart.

Question now is why the heck my OH seems to be restarting without any obvious reason. Another thing that hasn’t happened before…

Ok. Something weird is definitely going on here. Seems like OH is periodically purging my entire log folder and starting from scratch. Look at these two listings of the log folder, about one hour passed between them:

malmgren@rockpi:/var/log/openhab$ ls -alh
totalt 3,8M
drwxr-xr-x  2 openhab openhab 4,0K dec 30 20:40 .
drwxr-xr-x 13 root    root    4,0K nov 25 10:42 ..
-rw-r--r--  1 openhab openhab    0 dec 31 00:00 audit.log
-rw-r--r--  1 openhab openhab  97K dec 31 11:04 events.log
-rw-r--r--  1 openhab openhab 203K dec 30 20:40 events.log.1
-rw-r--r--  1 openhab openhab 3,5M dec 31 11:04 openhab.log
-rw-r--r--  1 openhab openhab  633 dec 30 20:30 openhab.log.1
-rwxr-xr-x  1 openhab openhab    0 dec 31 00:00 Readme.txt
malmgren@rockpi:/var/log/openhab$ ls -alh
totalt 716K
drwxr-xr-x  2 openhab openhab 4,0K dec 31 12:15 .
drwxr-xr-x 13 root    root    4,0K nov 25 10:42 ..
-rw-r--r--  1 openhab openhab    0 dec 31 12:15 audit.log
-rw-r--r--  1 openhab openhab 102K dec 31 12:31 events.log
-rw-r--r--  1 openhab openhab 698K dec 31 12:31 openhab.log
-rwxr-xr-x  1 openhab openhab    0 dec 31 00:00 Readme.txt

Nothing in any of the logs are older than 12:15 today, anything older than that is completely disappeared. Anyone knows what’s going on?

Also another weird thing is that my new events.log after this happened starts with a huge block of “^@^@^@^@^@^@^@^@^@^@^@^@^@” (seems to be about 205 000 of them). Wtf?

edit: Actually, this might be something that Armbian is doing. I just noticed the following mount:

/dev/zram0 on /var/log type ext4 (rw,relatime,discard)

So I might be barking up the wrong tree. Guess I’ll have to continue investigating somewhere else.

openHABian with ZRAM enabled? That or a failing SD card are about the only things I can think of that might do something like that.

Yes, that does look like a zram configuration. That puts /var/log into RAM instead of writing to the SD card (saving lots of writes and the card from wearing out). Given that it’s in RAM, to preserve it the files would need to be flushed to disk periodically. I’m no expert but that discard implies to me that it doesn’t write to disk which means any restart of the machine or restart of the ZRAM service will lose all the files.

Same issue here.
Upgraded today to OH3 and the logs were working as usual. After several hours, it stops logging suddenly.

My permissions were set correct except the current log file (events.log + openhab.log) … the owner was set to root here. Changed that and restarted OH3 and its now logging again.

I also tried the dev console in OH3, unfortunately its defintive no alternative for me and for the poll: I am definitely a power user of the frontail log :smiley:

Best

I stumbled on this thread, having the events.log issue (events.log is empty and idle).

I see there is a log4j2.xml mentioned in this thread but I have no such file, assuming I’m looking in the right place:

$ find /var/lib/openhab -type f -name "*.xml"
/var/lib/openhab/etc/org.apache.karaf.features.xml
/var/lib/openhab/etc/jetty.xml

I’m on Raspbian, installing openHAB as a Debian package from the bintray.com stable repo.

I accepted all suggested file/configuration changes during the upgrade. Also, my etc/org.ops4j.pax.logging.cfg is not a single line entry as mentioned above so I’m wondering what else went wrong with my upgrade, but that’s a different discussion.

I upgraded from openHAB 2.5 to 3.0. I did a quick search on a couple of the openHAB GitHub repos (openhab-core, openhab-bundles) and didn’t find anything, so perhaps this is generated during the installation as opposed to copied-and-modified.

At this point, I am wondering if someone could please point me to an example log4j2.xml and let me know where it should exist, i.e. what is the value of ${karaf.etc}. I’m having some bizarre value changes that I’m trying to troubleshoot and the events.log is a valuable tool to observe Item value changes.

1 Like

Thanks a lot! I have two quick follow-up questions:

  1. Does the log4j2.xml belong in /var/lib/openhab/etc? If not, where should it go?
    EDIT-2: Confirmed!
  2. If I want to disable openHAB’s log rotation, do I set the values of SizeBasedTriggeringPolicy to “0”?
    EDIT-2: Will have to experiment with this some more, commenting out SizeBasedTriggeringPolicy does not work.