[SOLVED] Log4j doesn't do what it should

  • Platform information:
    • Hardware: Raspberry Pi 3 Mod. B
    • OS: newest version of openHABian (Linux sh2 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux)
    • Java Runtime Environment: openjdk version “1.8.0_152”
    • openHAB version: 2.5.0~S1548-1 (Build #1548)

I have been trying for some time to ban various log messages from the frontail and the event log file. Unfortunately without success.

What I have
Lines 01 and 02 are a test error and warning. That’s fine and should be there.
Lines 03 and 04 are the channel trigger events from LogReader binding. I want to remove them.
Lines 05 and 06 are the item changed events from the LogReader binding items. I want to remove them.
Lines 07 and 08 are really bad. Because I write all errors and warnings into two digest items to send them at a specific time. As you see the messages look like they just happend. I really need to remove them. :slight_smile:

01 2019-03-06 19:19:00.913 [ERROR] [.eclipse.smarthome.model.script.test] - Test error
02 2019-03-06 19:19:00.920 [WARN ] [.eclipse.smarthome.model.script.test] - Test warning
03 2019-03-06 19:19:01.019 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newErrorEvent triggered 2019-03-06 19:19:00.913 [ERROR] [.eclipse.smarthome.model.script.test] - Test error
04 2019-03-06 19:19:01.036 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newWarningEvent triggered 2019-03-06 19:19:00.920 [WARN ] [.eclipse.smarthome.model.script.test] - Test warning
05 2019-03-06 19:19:01.040 [vent.ItemStateChangedEvent] - LogReader_LastErrorEvent changed from 2019-03-06 14:26:56.781 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'NotifyAboutChangeFeinstaubalarmState': The name 'AudioMessage' cannot be resolved to an item or type; line 20, column 2, length 12 to 2019-03-06 19:19:00.913 [ERROR] [.eclipse.smarthome.model.script.test] - Test error
06 2019-03-06 19:19:01.046 [vent.ItemStateChangedEvent] - LogReader_LastWarningEvent changed from 2019-03-06 14:27:08.192 [WARN ] [nal.protocol.ZWaveTransactionManager] - NODE 3: Not initialized (ie node unknown), ignoring message. to 2019-03-06 19:19:00.920 [WARN ] [.eclipse.smarthome.model.script.test] - Test warning
07 2019-03-06 19:19:01.141 [vent.ItemStateChangedEvent] - ErrorDigest changed from to
2019-03-06 19:19:00.913 [ERROR] [.eclipse.smarthome.model.script.test] - Test error
08 2019-03-06 19:19:01.151 [vent.ItemStateChangedEvent] - WarnDigest changed from to
2019-03-06 19:19:00.920 [WARN ] [.eclipse.smarthome.model.script.test] - Test warning

What I want to do
So I want to suppress everything from the LogReader addon and the events from ErrorDigest and WarnDigest.

What I did
I remembered my time as a programmer and looked in the log4j documentation for the appropriate filter. The regex filter is what I need. I configured it. And… nothing. It didn’t worked. I searched and found: openHAB - Filtering event logs. It was the same configuration as I had. But it doesn’t worked either. Here is my current configuration.

log4j2.appender.event.filter.foo.type = RegexFilter
log4j2.appender.event.filter.foo.regex = .*(ErrorDigest|WarnDigest|logreader).*
log4j2.appender.event.filter.foo.useRawMsg = false
log4j2.appender.event.filter.foo.onMatch = DENY
log4j2.appender.event.filter.foo.onMismatch = ALLOW

And what I tried so far:

  1. Different types of the regex.
  2. useRawMsg with value true and false. Although I am sure that this parameter can not be the cause of the problem.
  3. log4j2.appender.event.filter.foo.onMismatch also with the spelling onMisMatch and also with value NEUTRAL.

As soon as I activate the lines, there are no more entries or it is simply not filtered.

Does anyone of you have any idea what the cause might be? Is there something openHAB-specific, what prevents the suppressing? Or has the re-integration of ESH changed a bit? I really do not know how to continue.

Not sure if this is your problem. But you’re using ALLOW, but the doc and example use ACCEPT

I don’t know why, but that worked for me…

log4j2.appender.event.filter.regfil.type = RegexFilter
log4j2.appender.event.filter.regfil.regex = .*(WarnDigest|ErrorDigest|logreader:reader:openhablog:newErrorEvent|logreader:reader:openhablog:newWarningEvent|LogReader_LastErrorEvent|LogReader_LastWarningEvent).*
log4j2.appender.event.filter.regfil.useRawMsg = false
log4j2.appender.event.filter.regfil.onMatch = DENY
log4j2.appender.event.filter.regfil.onMisMatch = ACCEPT