I’m new to OH2 (and OH for that matter) and I’m developing a new binding. For some reason, logging does not seem to work for me. Here’s how I create a logger in my thing handler:
private Logger logger = LoggerFactory.getLogger(HeatSourceHandler.class);
but for some reason, calls to logger.debug(…) and even logger.info(…) don’t produce any output in userdata/openhab.log.
I have verified in the Karaf console, that that the log level is set appropriately. Here’s the excerpt of the output of log:list
Logger | Level
ROOT | DEBUG
org.openhab.binding.xyz | DEBUG
With xyz being the name of my bundle (sorry for the secrecy - can’t reveal at this time as the company I’m working for has not signed off on me publishing this). I can confirm that the code with the log statement is actually called (System.out.println("…") next to the log statement IS producing output.
Can anyone give me a hint what I’m missing here?
Thanks and cheers,
Welcome at openHAB
don’t produce any output in userdata/openhab.log.
I hope you mean
But you are right, the
log:set command does not influence the logging level of that file - they stick to what is defined in here.
Usually for debugging you simply stay in the console. If you do a
log:display you should see all your info and debug messages.
Thanks for the lighting fast response, Kai. That worked like a charm.
One followup question, though. I accidentally used a wrong case when I set the log level for the bundle (org.openhab.binding.Xyz instead of org.openhab.binding.xyz). Overwriting the existing, wrong log level entry with the correctly cased version doesn’t work for some reason (it is apparently ignored). As a result, I still can’t log anything for that particular package other than the default log level. Do you know how to reset log level settings? If it’s too complicated, I can always create a clean new instance (and pay for my mistake ;-))
log:set DEFAULT org.openhab.binding.Xyz
This should remove the entry again from
Btw, all this is standard Karaf, it is nothing special to openHAB. So this page might be your best friend
Perfect! Thanks again, Kai.