Logging updates of specific items in a separate file

I know how to make bindings or rules log into separate files, but what about items? I’ve got a few new items which receive an MQTT update every second, so I want those updates filtered out from the main event log…

Thanks for anyone’s help!

A regex filter surpresses the entries completely. They still show up in the MainUI log reader, which is just in physical memory.

Not easily.

openhab.log is the combination of all sorts of loggers from different parts of OH so it’s easy to identify a specific logger (e.g. for a specific binding) and change its configuration to log somewhere.

events.log comes only comes from one logger, the event bus. You can’t just configure a new appender in log4j2.xml and tell it to log certain lines to another file.

So your choices are:

  1. Set of a REGEX filter on events.log to suppress the Items you don’t want to see and then configure a new appender and then configure a new appender and set of loggers with a REGEX filter to suppress everything except the Items you want to filter into another file.

  2. Suppress updates from all Items. By default, only changes are logged already.

  3. To limit the number of changes you see, you can use the round profile so the Item changes less often, assuming the Item represents a sensor that’s just a little noisy (e.g. temperature or humidity sensors).

  4. Leave it and use your existing tools to filter as you look at/watch the logs.

Personally, I think 1 is more work than it’s worth and will be a little bit brittle. There are several posts about. Here is another example: Log filtering in OH 3 - #22 by markus7017.

2 should already be your configuration unless you did not misspeak and you really do mean updates instead of changes.

3 is what I do for the few chatty Items I have. I don’t really want these filling up my persistence and triggering rules unnecessarily either so it’s win-win. I don’t really need to process a difference of 0.01 °F. For all purposes that’s the same reading.

4 is always what I recommend, see How to watch and look through logging

1 Like