Separate zWave log file?

I found the posting by @rlkoshak (Taming openHAB 2 Logging) and updated org.ops4j.pax.logging.cfg adding the logger and the appender,

# zwave logger
log4j.logger.org.openhab.binding.zwave = TRACE, zwave, osgi:*
log4j.additivity.org.openhab.binding.zwave = false

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

Restarted openhab… And… nothing…

I realise that the post is old (Last year), but it does say it was updated… And it appears to be consistent with the wording in the openhab2 logging page (http://docs.openhab.org/administration/logging.html)

zWave still logs with everything else into openhab.log and events.log. I’ve also tried to set zWave logging to DEBUG in the console (After eventually finding start_debug.sh and then working out it needs to be run as openhab, not as root because it doesn’t work when started as root)…

But nothing on the logging side changed…

openhab> set LEVEL DEBUG org.openhab.binding.zwave
openhab>

I think I’m losing my marbles here. Certainly the will to live… 2.2.0-1 appears to be anything but stable for me. And trying to determine why is driving me nuts.

Hmm… Because the docs are wrong?

The config file actually uses log4j2… e.g.

# OSGi appender
log4j2.appender.osgi.type = PaxOsgi
log4j2.appender.osgi.name = OSGI
log4j2.appender.osgi.filter = *

Changing the logger and appender to use the same… And it’s no longer ignored… But still doesn’t work… I now have a new error on startup in the console…

penhab@piman-202:~$ /usr/share/openhab2/start_debug.sh
Launching the openHAB runtime...
Listening for transport dt_socket at address: 5005
13:58:22.989 [CM Configuration Updater (ManagedService Update: pid=[org.ops4j.pax.logging])] ERROR org.apache.felix.configadmin - [org.osgi.service.log.LogService, org.knopflerfish.service.log.LogService, org.ops4j.pax.logging.PaxLoggingService, org.osgi.service.cm.ManagedService, id=33, bundle=6/mvn:org.ops4j.pax.logging/pax-logging-log4j2/1.10.1]: Unexpected problem updating configuration org.ops4j.pax.logging
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1967) [?:?]
	at org.apache.logging.log4j.util.PropertiesUtil.partitionOnCommonPrefixes(PropertiesUtil.java:293) [5:org.ops4j.pax.logging.pax-logging-api:1.10.1]
	at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationBuilder.build(PropertiesConfigurationBuilder.java:155) [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1]
	at org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory.getConfiguration(PropertiesConfigurationFactory.java:56) [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1]
	at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.doUpdate(PaxLoggingServiceImpl.java:206) [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1]
	at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.updated(PaxLoggingServiceImpl.java:158) [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1]
	at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.updated(PaxLoggingServiceImpl.java:426) [6:org.ops4j.pax.logging.pax-logging-log4j2:1.10.1]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1479) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1435) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [7:org.apache.felix.configadmin:1.8.16]
	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [7:org.apache.felix.configadmin:1.8.16]
	at java.lang.Thread.run(Thread.java:748) [?:?]

                          __  _____    ____
  ____  ____  ___  ____  / / / /   |  / __ )
 / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  |
/ /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/
    /_/                        2.2.0
                               Release Build

Well, the docs are not really wrong but outdated. Until oh2.1 log4j was used and the docs are ok for this.

With the introduction of oh2.2 logging was changed to log4j2 as you already noticed.

A nice example how to configure it can be found here Log4j2 Sample Config

# zwave
log4j2.logger.zwave.name = org.openhab.binding.zwave
log4j2.logger.zwave.level = TRACE
log4j2.logger.zwave.additivity = false
log4j2.logger.zwave.appenderRefs = zwave
log4j2.logger.zwave.appenderRef.zwave.ref = zwave
log4j2.appender.zwave.name = zwave
log4j2.appender.zwave.type = RollingRandomAccessFile
log4j2.appender.zwave.fileName = /var/log/openhab2/zwave.log
log4j2.appender.zwave.filePattern = /var/log/openhab2/zwave.log.%i
log4j2.appender.zwave.immediateFlush = true
log4j2.appender.zwave.append = true
log4j2.appender.zwave.layout.type = PatternLayout
log4j2.appender.zwave.layout.pattern = %d{dd-MMM-yyyy HH:mm:ss.SSS} [%-5.5p] [%-50.50c] - %m%n
log4j2.appender.zwave.policies.type = Policies
log4j2.appender.zwave.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.zwave.policies.size.size = 1000MB
log4j2.appender.zwave.strategy.type = DefaultRolloverStrategy
4 Likes

Thanks @sipvoip. That worked and now I can get the zWave logs for the issues.

The description in the Admin Guide here didn’t work for me, but thanks to the example here it works now (zwave written in small letters). Thanks! :grinning: