Logging: Syntax for RegEx-expression excluding 'matches' in search criteria

Im trying to clean up the event logs and have successfully edited the file ‘log4j2.xml’ found in ‘/var/lib/openhab/etc/’ to exclude certain matches.

I would like to distinguish ‘temp_example’ from ‘target_temp_example’ so that ‘target_temp_example’ is included in logs but ‘temp_example’ is not. I did not yet succeed though.

What I have tested.

  • <RegexFilter onMatch="DENY" onMismatch="NEUTRAL" regex=".*(temp_example).*"/>
    Result: filters out both ‘temp_example’ and ‘target_temp_example’.

  • Adding a ‘^’ in the regex-expression → ‘^temp_example’ should state that string should be started with ‘temp_example’ to match.
    <RegexFilter onMatch="DENY" onMismatch="NEUTRAL" regex=".*(^temp_example).*"/>
    Result: both ‘target_temp_example’ and ‘temp_example’ is present in the log.

  • Using two consecutive filters.
    <RegexFilter onMatch="ACCEPT" onMismatch="NEUTRAL" regex=".*(target_).*"/> <RegexFilter onMatch="DENY" onMismatch="NEUTRAL" regex=".*(temp_example).*"/>
    Result: only the first filter is active and both ‘target_temp_example’ and ‘temp_example’ is present in the log.

I believe it should be possible and the error is within the syntax. Its not the end of the world if not solved (and it can be solved by renaming or other means), its just a bit frustrating that I cannot get the behavior I want. Any advice appreciated, thanks!

Changed my approach slightly after some research.

Background for me is I am getting a lot of new items in the system. These items update frequently and spam the eventlog.

Im using the eventlog mostly through the web (http://openhabian:9001/) as a way to diagnose rules-engine mostly. Ie, wake up in the morning to check if the automation was ok during the night. If not use the eventlog to backtrace behaviour. With all those values changing constantly I would get like less than 30 minutes logged events (only containing openhab.event.ItemStateChangedEvent) and none of my rules-diagnostics logInfo.

Instead of using the regex-way to DENY certain entires a different approach is therefore to turn down level on “openhab.event.ItemStateChangedEvent” in the log4j2.xml-file. If and when I will need those updates I can turn on logging again.

<!-- added to verbose updates based on item value changes -->
<Logger level="WARN" name="openhab.event.ItemStateChangedEvent"/>
<!-- changed from INFO to WARN -->
<Logger level="WARN" name="openhab.event.ItemStateEvent"/>