I’ve noticed a couple things about logging in openHAB 3. Can anyone shed some light based on your experience?
I see the log4j2 logging config file has changed to use the XML format. In openHAB 2, when you changed the logging config file, the changes would take effect immediately. However, whenever I change the log4j2.xml file, the changes are not applied. Instead, I need to restart openHAB for the changes to take effect. Is this the way it works now, or is there something I’m not understanding.
It would be nice to be able to use the xinclude feature to keep my custom logging changes separate from the standard system logging configuration. However, I’ve not been able to get this to work. Does anyone have a working example?
Does anyone have a working example of how to configure a dedicated log file for a specific binding (e.g. zwave.log for the zwave binding)?
There is a long issue that I even spent a good number of hours trying to solve. I think the final conclusion was and remains that this is only sort of possible. The problem is when you change the logging level and settings in the Karaf console, it actually edits/appends to the logging config. I spent quite some time working on it and didn’t get very far. Unfortunately I can’t find that issue again. IIRC, @rossko57 participated on that issue and took a shot at it too, maybe his memory is better than mine. Of course there were two parts to that issue, one was moving to XML and the other was figuring out how to to the xinclude. It looks like the XML part is solved at least. I can’t find the PR where this was implemented either.
The format of the logger config in OH 3 has changed from properties to XML. The binding docs only show properties and therefore is no longer applicable in OH 3.
Did you ever identify a way to reread the XML file without a restart of OH? Having the same issue.
EDIT: Not the best work around but “touch org.ops4j.pax.logging.cfg” triggers the update without restart. Probably needs a bug to track the xml file and not just the cfg.
In OH2, when you would add config files for things like zwave above, it would peel those configs out of openhab.log (which was nice when you were waiting for a failure so you weren’t flooding your logs out otherwise). In OH3, it seems to duplicate the log entries in both openhab.log and the new log file. For example, I’m peeling lutron off right now with the following:
Do we still have te reboot to apply the changes in the XML file? It’s very unconvenient for me, because in OH3 that breaks the LogTail and the GoogleTTS voice, so with every change I have to reinstall (unable to do that for GoogleTTS) them…
Awesome. I think this would be worthwhile to submit for inclusion in the core, but maybe backing off the interval a little bit. Seems to me that one minute or even five minutes would be sufficient for seeing your changes relatively quickly.