Hello I tried below script , but the items UG_Waschkueche_Trockner_CurrTime and EG_Kueche_Spuelm_CurrTime
still in the event log
Have i made a new appendar ?
I had some trouble getting this to work, even after touching the org.ops4j.pax.logging.cfg file to have OH pick up the changes. It’ll only update when I fully restart the openHAB service. Not great, but once I have all of my filters in it’s not a big deal.
Hi,
trying to set a filter in the new openHAB3 filter config file but I simply cannot get it to filter anything. The entries in the log below is what I am trying to filter out.
System:
openHAB 3.01 official release
OS: Windows 10
From what I understand I should add something along this line in the log4j2.xml file after PatternLayout:
I have also tried NEUTRAL instead of ACCEPT - no change. I have also tried to put the regex="… parameter just after RegexFilter. Same result.
I have restarted OH several times. I put the line in several appenders: Console appender, Rolling file appender and Event log appender, just to try and get it to work as expected. But I fail and now I don’t really know how to go on. I have read the posts about how to append and for me it looks right. But OH probably only does what I tell it to do, it is me not knowing how to define it correctly.
Am I doing something wrong that possibly is obvious to someone else? Some input would be appreciated.
The complete config file (my changes are in the beginning):
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Configuration monitorInterval="30">
<Appenders>
<!-- Console appender not used by default (see Root logger AppenderRefs) -->
<Console name="STDOUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
<RegexFilter onMatch="DENY" onMismatch="ACCEPT" regex=".*(Curtains).*"/>
</Console>
<!-- Rolling file appender -->
<RollingFile fileName="${sys:openhab.logdir}/openhab.log" filePattern="${sys:openhab.logdir}/openhab.log.%i" name="LOGFILE">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
<RegexFilter onMatch="DENY" onMismatch="ACCEPT" regex=".*(Curtains).*"/>
<Policies>
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="16 MB"/>
</Policies>
</RollingFile>
<!-- Event log appender -->
<RollingRandomAccessFile fileName="${sys:openhab.logdir}/events.log" filePattern="${sys:openhab.logdir}/events.log.%i" name="EVENT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
<RegexFilter onMatch="DENY" onMismatch="ACCEPT" regex=".*(Curtains).*"/>
<Policies>
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="16 MB"/>
</Policies>
</RollingRandomAccessFile>
<!-- Audit file appender -->
<RollingRandomAccessFile fileName="${sys:openhab.logdir}/audit.log" filePattern="${sys:openhab.logdir}/audit.log.%i" name="AUDIT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
<Policies>
<OnStartupTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="8 MB"/>
</Policies>
</RollingRandomAccessFile>
<!-- OSGi appender -->
<PaxOsgi filter="*" name="OSGI"/>
</Appenders>
<Loggers>
<!-- Root logger configuration -->
<Root level="WARN">
<AppenderRef ref="LOGFILE"/>
<AppenderRef ref="OSGI"/>
</Root>
<!-- Karaf Shell logger -->
<Logger level="OFF" name="org.apache.karaf.shell.support">
<AppenderRef ref="STDOUT"/>
</Logger>
<!-- Security audit logger -->
<Logger additivity="false" level="INFO" name="org.apache.karaf.jaas.modules.audit">
<AppenderRef ref="AUDIT"/>
</Logger>
<!-- openHAB specific logger configuration -->
<Logger level="INFO" name="org.openhab"/>
<Logger level="ERROR" name="openhab.event.ItemStateEvent"/>
<Logger level="ERROR" name="openhab.event.ItemAddedEvent"/>
<Logger level="ERROR" name="openhab.event.ItemRemovedEvent"/>
<Logger level="ERROR" name="openhab.event.ItemChannelLinkAddedEvent"/>
<Logger level="ERROR" name="openhab.event.ItemChannelLinkRemovedEvent"/>
<Logger level="ERROR" name="openhab.event.ThingStatusInfoEvent"/>
<Logger level="ERROR" name="openhab.event.ThingAddedEvent"/>
<Logger level="ERROR" name="openhab.event.ThingUpdatedEvent"/>
<Logger level="ERROR" name="openhab.event.ThingRemovedEvent"/>
<Logger level="ERROR" name="openhab.event.InboxUpdatedEvent"/>
<Logger level="ERROR" name="openhab.event.RuleStatusInfoEvent"/>
<Logger level="ERROR" name="openhab.event.RuleAddedEvent"/>
<Logger level="ERROR" name="openhab.event.RuleRemovedEvent"/>
<Logger level="ERROR" name="openhab.event.StartlevelEvent"/>
<Logger level="ERROR" name="openhab.event.AddonEvent"/>
<Logger additivity="false" level="INFO" name="openhab.event">
<AppenderRef ref="EVENT"/>
<AppenderRef ref="OSGI"/>
</Logger>
<Logger level="ERROR" name="javax.jmdns"/>
<Logger level="ERROR" name="org.jupnp"/>
<!-- This suppresses all Maven download issues from the log when doing feature installations -->
<!-- as we are logging errors ourselves in a nicer way anyhow. -->
<Logger level="ERROR" name="org.ops4j.pax.url.mvn.internal.AetherBasedResolver"/>
<!-- Filters known issues of pax-web (issue link to be added here). -->
<!-- Can be removed once the issues are resolved in an upcoming version. -->
<Logger level="OFF" name="org.ops4j.pax.web.pax-web-runtime"/>
<!-- Filters known issues of lsp4j, see -->
<!-- https://github.com/eclipse/smarthome/issues/4639 -->
<!-- https://github.com/eclipse/smarthome/issues/4629 -->
<!-- https://github.com/eclipse/smarthome/issues/4643 -->
<!-- Can be removed once the issues are resolved in an upcoming version. -->
<Logger level="OFF" name="org.eclipse.lsp4j"/>
<!-- Filters warnings for events that could not be delivered to a disconnected client. -->
<Logger level="ERROR" name="org.apache.cxf.jaxrs.sse.SseEventSinkImpl"/>
<!-- Filters known issues of KarServiceImpl, see -->
<!-- https://github.com/openhab/openhab-distro/issues/519#issuecomment-351944506 -->
<!-- Can be removed once the issues are resolved in an upcoming version. -->
<Logger level="ERROR" name="org.apache.karaf.kar.internal.KarServiceImpl"/>
<!-- Filters warnings about unavailable ciphers when JCE is not installed, see -->
<!-- https://github.com/openhab/openhab-distro/issues/999 -->
<Logger level="ERROR" name="org.apache.karaf.shell.ssh.SshUtils"/>
<!-- Filters known issues of javax.mail, see -->
<!-- https://github.com/openhab/openhab-addons/issues/5530 -->
<Logger level="ERROR" name="javax.mail"/>
<!-- Filters disconnection warnings of the ChromeCast Java API, see -->
<!-- https://github.com/openhab/openhab-addons/issues/3770 -->
<Logger level="ERROR" name="su.litvak.chromecast.api.v2.Channel"/>
<!-- Added by Karaf to prevent debug logging loops, see -->
<!-- https://issues.apache.org/jira/browse/KARAF-5559 -->
<Logger level="ERROR" name="org.apache.sshd"/>
<Logger level="INFO" name="org.openhab.binding.shelly"/>
</Loggers>
</Configuration>
These are the events I try to filter out when I have log:tail running in the cmd-window of Karaf:
16:25:46.190 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 0.0 to 100.0
16:25:48.518 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 100.0 to 0.0
16:26:01.196 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 0.0 to 100.0
16:26:04.045 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 100.0 to 0.0
16:26:17.548 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 0.0 to 100.0
16:26:19.355 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 100.0 to 0.0
16:27:02.285 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Curtains' changed from 0.0 to 100.0
You only need the RegexFilter to be defined for the file you’re trying to modify. So for events.log, it’s the <!-- Event log appender -->. Remove it everyywhere else you have it.
You should also change onMismatch="ACCEPT" to onMismatch="NEUTRAL".
If you have entries in openhab.log that you also want to filter, add a similar filter line to <!-- Rolling file appender -->
I’m not sure if the order matters in a RegexFilter, but in mine I have them ordered as regex, onMatch, and onMismatch.
Than you both of you for your replies! Unfortunately the OSGI log does not accept a regex filter but I think this is up to me to research. The parameters seems to be different in this case. I will look into it - but big thanks for helping me a bit on the way, much appreciated!
I’m confused. Didn’t you start this thread and have it working at one point? Mine is based on what you previously posted, and it works.
It looks like you’ve made a lot of changes, and somewhere along the way you removed the parentheses from your RegexFilter. That’s most likely the reason why it’s not doing anything.
<RegexFilter regex=".*_Heartbeat|etc.*"
Should be:
<RegexFilter regex=".*(_Heartbeat|etc).*"
Beyond the regex, I note that:
The RegexFilter line has been moved ahead of PatternLayout.
The SizeBasedTriggeringPolicy has changed from 16 MB to 4 MB.
I don’t know if these are problems, but I’m curious as to why you made these edits.
hehe, me too, I had it working, but for some reason…
I noticed that the first example above defines the filter for LOGFILE. Now my understanding is that this doesn’t make sense, because those events are written to events.log/EVENT so I moved the line (after it didn’t worked as expected). Then I tried @ssalonen’s approach, but this also doesn’t work.
I tried with and without brackets. In fact () puts the result in group 1. Log4j – Log4j Filters shows an example without (), but I tried both.
This drives nuts
@ssalonen@wborn Do you have an idea what’s wrong with my config above?