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

**URL:** <https://community.openhab.org/t/logging-syntax-for-regex-expression-excluding-matches-in-search-criteria/138730>\
**Category:** Beginners\
**Tags:** regex, logging\
**Created:** [September 8, 2022, 9:49am UTC](https://community.openhab.org/t/logging-syntax-for-regex-expression-excluding-matches-in-search-criteria/138730 "2022-09-08T09:49:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![perIpI](https://community.openhab.org/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@perIpI](https://community.openhab.org/u/perIpI)\
**Post date:** [September 8, 2022, 9:49am UTC](https://community.openhab.org/t/logging-syntax-for-regex-expression-excluding-matches-in-search-criteria/138730/1 "2022-09-08T09:49:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![perIpI](https://community.openhab.org/letter_avatar_proxy/v4/letter/p/a87d85/32.png) [@perIpI](https://community.openhab.org/u/perIpI)\
**Post date:** [September 9, 2022, 8:19am UTC](https://community.openhab.org/t/logging-syntax-for-regex-expression-excluding-matches-in-search-criteria/138730/2 "2022-09-09T08:19:56Z")

</div>

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/](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.

```auto
<!-- 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"/>

```
