How to log mihome binding on DEBUG level?

Hi there,

I’m trying to log on DEBUG level in a separate file but it doesn’t work.

The code below is added to org.ops4j.pax.logging.cfg

# mihome Logger = org.openhab.binding.mihome
log4j2.logger.mihome.level = DEBUG
log4j2.logger.mihome.additivity = false
log4j2.logger.mihome.appenderRefs = mihome
log4j2.logger.mihome.appenderRef.mihome.ref = mihome

# mihome File Appender - mihome.log = mihome
log4j2.appender.mihome.type = RollingRandomAccessFile
log4j2.appender.mihome.fileName = ${openhab.logdir}/mihome.log
log4j2.appender.mihome.filePattern = ${openhab.logdir}/mihome.log.%i
log4j2.appender.mihome.immediateFlush = true
log4j2.appender.mihome.append = true
log4j2.appender.mihome.layout.type = PatternLayout
log4j2.appender.mihome.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.mihome.policies.type = Policies
log4j2.appender.mihome.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.mihome.policies.size.size = 10MB
log4j2.appender.mihome.strategy.type = DefaultRolloverStrategy
log4j2.appender.mihome.strategy.max = 10

It creates the file mihome.log but it’s always 0 KB.

When looking at log:list in karaf console the level is on WARN

openhab> log:list
Logger                                             │ Level
ROOT                                               │ WARN
javax.jmdns                                        │ ERROR
org.apache.karaf.jaas.modules.audit                │ INFO
org.apache.karaf.kar.internal.KarServiceImpl       │ ERROR                     │ OFF
org.apache.sshd                                    │ ERROR
org.eclipse.jetty.util.thread.ThreadPoolBudget     │ ERROR
org.eclipse.smarthome                              │ INFO
org.jupnp                                          │ ERROR
org.openhab                                        │ INFO
org.openhab.binding.mihome                         │ WARN
org.openhab.binding.zwave                          │ DEBUG
org.ops4j.pax.url.mvn.internal.AetherBasedResolver │ ERROR
org.ops4j.pax.web.pax-web-runtime                  │ OFF
smarthome.event                                    │ INFO
smarthome.event.InboxUpdatedEvent                  │ ERROR
smarthome.event.ItemAddedEvent                     │ ERROR
smarthome.event.ItemRemovedEvent                   │ ERROR
smarthome.event.ItemStateEvent                     │ ERROR
smarthome.event.ThingAddedEvent                    │ ERROR
smarthome.event.ThingRemovedEvent                  │ ERROR
smarthome.event.ThingStatusInfoEvent               │ ERROR

When changing the log level via karaf log:set TRACE org.openhab.binding.mihome it sets the value in org.ops4j.pax.logging.cfg but doesn’t log. AND in log:list it’s still WARN

# mihome Logger = org.openhab.binding.mihome
log4j2.logger.mihome.level = TRACE
log4j2.logger.mihome.additivity = false
log4j2.logger.mihome.appenderRefs = mihome
log4j2.logger.mihome.appenderRef.mihome.ref = mihome

I believe you need to restart the binding after setting the log level in the console.

I even did a shutdown and reboot. The outcome still is …

Are all the entries in your config exactly correct? Look at the example here for zwave. Some entries are lower case, some have first cap, and some are all capital letters.

You likely need to look at the normal log entries or logs in Karaf to determine the proper settings.

1 Like

Thanks for the hint …

I use the Z-Wave code as a template and did search & replace of all “zwave” (not case sensitive) into “mihome” (all lowercase).

Where does one find the correct notation?

Ok - the problem seems to be solved :slight_smile:

# ZWave File Appender - ZWave.log = ZWAVE
log4j2.appender.ZWave.type = RollingRandomAccessFile
log4j2.appender.ZWave.fileName = ${openhab.logdir}/ZWave.log
log4j2.appender.ZWave.filePattern = ${openhab.logdir}/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{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.ZWave.policies.type = Policies
log4j2.appender.ZWave.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.ZWave.policies.size.size = 10MB
log4j2.appender.ZWave.strategy.type = DefaultRolloverStrategy
log4j2.appender.ZWave.strategy.max = 10
log4j2.logger.org_apache_sshd.level = ERROR = org.apache.sshd
log4j2.logger.org_openhab_binding_mihome.level = WARN = org.openhab.binding.mihome

The last two lines in the ZWave code are odd.
Mixed usage of karaf commands and config files for logging seems to cause unwanted behavior.

Now the logging of mihome works as expected.

1 Like