Logging to events and openhab logs

Seems at present logging for events is being done into both
events and openhab.log
So openhab.log is populated with a lot of ItemStateChangedEvent
Is there a way to change this?

I just discovered the same thing yesterday and opened an issue, first in Eclipse Smarthome but it was closed quickly, then in openHAB distro project. I hope we could have an answer.

FTR: https://github.com/openhab/openhab-distro/issues/224

Yes, I agree it should not be in openhab.log, but it should be on the console when doing a “log:tail”.
I thought I had configured it to work this way by https://github.com/openhab/openhab-distro/blob/master/distributions/distribution-resources/src/main/resources/etc/org.ops4j.pax.logging.cfg#L6, but then it seems it does not work as expected.
If you find out, what to change in this file, please create a PR - thanks!

Is there any way to enable circular logging? I.e. so the oldest logs are purged rather than just seemingly increasing forever?

I have 100MB of logs from the past 10 days alone built up…

Old logs should get purged, defauly settings are:

log4j.appender.out.maxFileSize=10MB log4j.appender.out.maxBackupIndex=10

So in you case the max should now be reached.

Ah OK cool, thanks.

How do I change these settings?

The config file for logging is org.ops4j.pax.logging.cfg and can be found in the runtime/karaf/etc/ folder (in case openHAB was installed via apt, the full path is: /usr/share/openhab2/runtime/karaf/etc/)

Please note: Currently the file org.ops4j.pax.logging.cfg will get overwritten with the default version on every update of openHAB. There is an issue on this.

Thanks for the help!

One more point. Switching DEBUG for the binding in karaf console - will the messages be written to openhab log? Or some other logging facility?

@moskovskiy82, by default the messages will be in the openhab.log

But you can also define you own log files. In order to do that, you need to add into the config file mention above:

A new file apppender:

# File appender - jk.log log4j.appender.jk=org.apache.log4j.RollingFileAppender log4j.appender.jk.layout=org.apache.log4j.PatternLayout log4j.appender.jk.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p [%-36.36c] - %m%n log4j.appender.jk.file=${openhab.logdir}/jk.log log4j.appender.jk.append=true log4j.appender.jk.maxFileSize=10MB log4j.appender.jk.maxBackupIndex=10

and a new logger:

# Logger - jk.log log4j.logger.org.eclipse.smarthome.model.script.JK = WARN, jk log4j.logger.org.eclipse.smarthome.model.script.JK.Sonos = DEBUG