Simple string filtering on the event log. Useful for filtering out high change items that don’t need constant log visibility.
Log configuration data using openhabian-pi is stored in the following file. Location may vary under other installation methods.
openHAB using log4j edit the file to add filter rules using the following methodology.
# Filtering Rules log4j.appender.event.filter.<your-filter-name>=org.apache.log4j.varia.StringMatchFilter log4j.appender.event.filter.<your-filter-name>.StringToMatch=<your_filter_string> log4j.appender.event.filter.<your-filter-name>.AcceptOnMatch=false
openHAB 2.2 uses log4j2 with a different syntax.
# Filtering Rules log4j2.appender.event.filter.<your-filter-name>.type = RegexFilter log4j2.appender.event.filter.<your-filter-name>.regex = .*(<your_filter_string1>|<string2>|<string3>|<etc>).* log4j2.appender.event.filter.<your-filter-name>.onMatch = DENY log4j2.appender.event.filter.<your-filter-name>.onMisMatch = ACCEPT
<your-filter-name> with a suitable filter name, and similarly
<your_filter_string> with the string you want to filter out. In my case I have a Smappee power meter which updates household power consumption on a second by second basis via an MQTT feed. The event data for this just fills the log up, so since upgrading to OH 2.2 have now updated my filter rule to the following.
Shout out to @kintrupf for the regex (OR) example shown in the posts further down and now edited into the example above.
# Jp - filter out stuff log4j2.appender.event.filter.smappee.type = RegexFilter log4j2.appender.event.filter.smappee.regex = .*power_smappee.* log4j2.appender.event.filter.smappee.onMatch = DENY log4j2.appender.event.filter.smappee.onMisMatch = ACCEPT
power_smappee being the name of my item in my set up. I haven’t tried it yet, but I don’t believe there should be any reason you can’t create multiple filters to filter out different sets of data, similar to the sun, moon astro examples in the linked pages.
DISCLAIMER: I don’t profess to be an expert on regex or log4j, this is just based on my own research, and once set up works well for me. If it helps you, excellent!, if it doesn’t work, I probably can’t tell you why it didn’t, sorry.