openHAB - Filtering event logs

I find this site to be of great help in testing regex. Put in your regex pattern and then copy/paste a chunk of your event.log. Note that I’m not sure how much you can paste into the text box.

I can’t get the log4j2 regex filter work on my events.log file. I’m running OH 2.5.0 M1 on openhabian.

I added the following 4 lines at the end of /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg

log4j2.appender.event.filter.uselessjunk.type = RegexFilter
log4j2.appender.event.filter.uselessjunk.regex = .*(Astro_(Sun|Moon|Civil|Nautic|Astro|Noon|Morning|Evening)|Wx_OWM_(Current|Forecast)|openweathermap_(weather_and_forecast|uvindex)).*
log4j2.appender.event.filter.uselessjunk.onMatch = DENY
log4j2.appender.event.filter.uselessjunk.onMisMatch = ACCEPT

I tested the regex online and it shows the matches on the sample input I provided.
When I restart openhab2, then I see the event log lines matching the regex are still logged in /var/log/openhab2/events.log.
What am I doing wrong?

EDIT: it now works

Hi, please can someone help me? MY configuration is not working:

Here are my errors/warnings i want to remove from openhab.log:

2019-03-06 15:51:07.240 [WARN ] [.binding.knx.internal.bus.KNXBinding] - Value '167310.0' could not be sent to the KNX bus using datapoint 'command DP 4/3/1 HeatPump_Stromzaehler, DPT main 0 id 12.001, low priority' - retrying one time: 12.001 Unsigned count: wrong value format: 167310.0

2019-03-06 15:51:07.240 [ERROR] [.binding.knx.internal.bus.KNXBinding] - Value '167310.0' could not be sent to the KNX bus using datapoint 'command DP 4/3/1 HeatPump_Stromzaehler, DPT main 0 id 12.001, low priority' - giving up after second try: 12.001 Unsigned count: wrong value format: 167310.0

And here is my pax4j-logging-config:

################# KNX Fehler ausbelenden ###########
# Filtering Rules
log4j2.appender.event.filter.KNXremove.type = RegexFilter
log4j2.appender.event.filter.KNXremove.regex = .*could not be sent to the KNX bus using datapoint.*
log4j2.appender.event.filter.KNXremove.onMatch = DENY
log4j2.appender.event.filter.KNXremove.onMisMatch = ACCEPT
#####################

If you want to filter openhab.log, don’t you want this to be

log4j2.appender.out.filter.KNXremove.type = RegexFilter
log4j2.appender.out.filter.KNXremove.regex = .*could not be sent to the KNX bus using datapoint.*
log4j2.appender.out.filter.KNXremove.onMatch = DENY
log4j2.appender.out.filter.KNXremove.onMisMatch = ACCEPT
1 Like

I changed event to out, but the errors and warnings still appear in my openhab.log.

Since when does it not work for you (anymore). Maybe I currently have the same problem:

Hmm. Then I’m not sure what’s going on.

I have the same problem. I guess I have the right logging settings (see below), but without effect. Actually the logs don’t even confirm that the logfile has been re-read, but I’m not sure if that is logged (if not, it should).

log4j2.appender.event.filter.CurrentCost.type = RegexFilter
log4j2.appender.event.filter.CurrentCost.regex = .*CurrentCost_xml. (there is a star after the point, but it is filtered out by the editor…)
log4j2.appender.event.filter.CurrentCost.useRawMsg = false
log4j2.appender.event.filter.CurrentCost.onMatch = DENY
log4j2.appender.event.filter.CurrentCost.onMisMatch = ACCEPT

Only thing that could be are the camel case. Try currentcost instead of CurrentCost.

It’s unfortunately not.

Sure it is… if you have your logging levels set do that you can see it :wink:

2019-03-15 17:10:21.681 [INFO ] [org.apache.felix.fileinstall] - Updating configuration from org.ops4j.pax.logging.cfg
1 Like

Ok, it’s unfortunately not per default, but: mea culpa! :blush:

Hi All,

I too am strugglign with these using the examples here.

Trying to filter the console log with:


log4j2.appender.event.filter.floodstop.type = RegexFilter
log4j2.appender.event.filter.floodstop.regex = .*(OpenHAB|UPS|yamahareceiver).*
log4j2.appender.event.filter.floodstop.onMatch = DENY
log4j2.appender.event.filter.floodstop.onMisMatch = ACCEPT

Trying to remove this:

08:25:05.705 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Memory_Used_Percent changed from 16.1 to 16.2
08:25:05.711 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Cpu_SystemUptime changed from 2156.5 to 2157.5
08:25:05.713 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Sensors_CpuTemperature changed from 39.0 to 38.0
08:25:05.715 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Cpu_Load changed from 1.4 to 1.2
08:25:05.717 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Memory_Available changed from 13405 to 13402
08:25:05.718 [INFO ] [smarthome.event.ItemStateChangedEvent] - OpenHAB_Memory_Available_Percent changed from 83.9 to 83.8
08:25:14.808 [INFO ] [smarthome.event.ItemStateChangedEvent] - UPS_Battery_Runtime changed from 1068 to 1109

Are you putting your filters right after the “# Event log appender” section, or are they at the very end of the file?

I think I had to locate the Regex filters right after that section to get it to work. Similarly, I think I didn’t get openhab.log filters to work until I put them right after the “# Rolling file appender” section.

2 Likes

for me this is working .
Added following entry EOF
pi@homepi:~ $ nano /var/lib/openhab2/etc/org.ops4j.pax.logging.cfgusing


log4j2.appender.event.filter.uselessjunk.type = RegexFilter
log4j2.appender.event.filter.uselessjunk.regex = .(Astro(Sun|Moon|Civil|Nautic|Astro|Noon|Morning|Evening)|Wx_OWM_|weather|forecast|uvindex|localforecast|System_openHAB|Swap_|CPU_Load|Network_PacketsSent|CPU_Uptime changed|System_CPU_Uptime|CPU_Threads|Network_Packets|Sun_Elevation|Moon_Elevation|Storage_Used).
log4j2.appender.event.filter.uselessjunk.onMatch = DENY
log4j2.appender.event.filter.uselessjunk.onMisMatch = ACCEPT

using the following setup:

log4j2.appender.event.filter.trackProgress.type = RegexFilter
log4j2.appender.event.filter.trackProgress.regex = .trackProgress.
log4j2.appender.event.filter.trackProgress.onMatch = DENY
log4j2.appender.event.filter.trackProgress.onMisMatch = ACCEPT

I have been able to filter out the spotify trackprogress events from the events.log file but these events still appear in the log:tail output.

How could I filter out the trackprogress events from the log:tail?

1 Like

I posted this already some time ago, but now I tried once again to filter out of events.log all ItemStateChangeEvent messages that contain the text CurrentCost. For this, I tried with the following text:

log4j2.appender.event.filter.CurrentCost.type = RegexFilter
log4j2.appender.event.filter.CurrentCost.regex = .*CurrentCost_xml.*
log4j2.appender.event.filter.CurrentCost.onMatch = DENY
log4j2.appender.event.filter.CurrentCost.onMisMatch = ACCEPT

I also tried with small case (currentcost instead of CurrentCost) but same non-effect.
I added this after the event log appender section of org.ops4j.pax.logging.cfg, as @rpwong suggested, but without success. Any more ideas?

Can you post an example of the message you’re trying to filter out?

This is the text I am trying to filter out this:
2019-05-22 22:04:19.621 [vent.ItemStateChangedEvent] - CurrentCost_xml changed from <msg><src>CC128-v1.48</src><dsb>01917</dsb><time>20:17:58</time><tmpr>23.9</tmpr><sensor>0</sensor><id>00079</id><type>1</type><ch1><watts>00399</watts></ch1></msg> to <msg><src>CC128-v1.48</src><dsb>01917</dsb><time>20:18:04</time><tmpr>23.9</tmpr><sensor>0</sensor><id>00079</id><type>1</type><ch1><watts>00399</watts></ch1></msg>
It is the item measuring energy consumption (besides temperature), and since it is updated every 5 seconds, I don’t like to fill up my logs with this.

Hmm, I’m not sure. For reference, here’s what mine looks like:

# custom filters for events.log
log4j2.appender.event.filter.uselessjunk.type = RegexFilter
log4j2.appender.event.filter.uselessjunk.regex = .*(string 1|string 2|etc).*
log4j2.appender.event.filter.uselessjunk.onMatch = DENY
log4j2.appender.event.filter.uselessjunk.onMisMatch = ACCEPT

Nothing jumps out to me as being significantly different, aside from me using brackets to contain multiple strings.

The only other thing I can think of is to clean your cache and restart, but I’m just guessing.

You need a capturing group…

log4j2.appender.event.filter.CurrentCost.regex = .*(CurrentCost_xml).*
1 Like