Shelly spamming log

Hello,
I searched a lot, but maybe I’m to dump to find the solution.
OH3.4, RPI4, Shell 3EM
When I view the log by using logtail (browser) I get showed every chnage in Voltage and other measurement of the shelly. This is spamming the whole log.
How can I reduce the loglevel for only the shelly binding to prevent showing every little change in measurement?
Sorry for asking that question as it must be solved somewhere because I will not be the only one with this problem, but I don’t find it. A little hint would be appreciated.
Thanks,
Ingo

You can edit log4j config to exclude certain items from logging.

The config if does in an xml file (log4j.xml or similar) and includes two file appenders: one for openhab.log and one for events.log

For specific syntax please check the general log4j help or maybe search the forum

Thanks, will se the doku.

In case you don’t find the correct syntax I can look it up once I am back home

I had a look, but it seems not to be “that easy”. The syntax changed several times while OH developed. When it’s not that big effort for you, would be nice to see your example.
Thanks

Which log are you talking about? It sounds like events.log. You can’t change what gets logged there from the binding because that’s not what’s logging there. That log contains all the events published to the event bus.

See How to watch and look through logging and openHAB - Filtering event logs.

If you set up a filter, you’ll have to translate that to XML. Here’s an example filter.

<RegexFilter regex=".*createTimer.*deprecated.*" onMatch="DENY" onMismatch="NEUTRAL"/>

You’ll have to adjust the regex and add that to the Event log appender.

Note, I’m of the opinion that either the events.log is useful or it isn’t. If it isn’t useful, disable it. If it is useful, its counter productive to redact it and hide some of what’s going on. There are lots of ways to filter logs on the fly (you can even do so in FronTail) to only see those lines you care about at that time without excluding them from the logs entirely.

1 Like

OK, Thanks Rich and Matze, I could figure it out with yours help.

Concerning Rich, to enable or disable the events.log, I see that a little different. Some Events, like open Windows or triggered PIR or something which happens not that often, but might be interesting when it happens I wanna see in the log. In contrast, the measurement reading of powersensors or there like are spamming the log so I don’t see the important stuff. Also the create big log files which wear out my ssd :slight_smile:

I like to give an example from my config now, for those, who search like me, and for myself when I search for it next time.

In the event log the logs which disturb me look loke that:

2022-12-21 20:17:22.467 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Power_Phase1_MainInputLine' changed from -26.32 to -21.19
2022-12-21 20:17:22.475 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Voltage_Phase1_MainInputLine' changed from 233.1 to 233.2
2022-12-21 20:17:23.488 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Power_Phase1_MainInputLine' changed from -21.19 to -19.91
2022-12-21 20:17:23.494 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PowerFactor_Phase1_MainInputLine' changed from -0.21 to -0.17
2022-12-21 20:17:24.471 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Power_Phase1_MainInputLine' changed from -19.91 to -24.02
2022-12-21 20:17:24.477 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Voltage_Phase1_MainInputLine' changed from 233.2 to 233.1
2022-12-21 20:17:25.472 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Power_Phase1_MainInputLine' changed from -24.02 to -18.33

So I took out the term “_MainInputLine” and put it in the regex. The config file (/var/lib/openhab/etc/log4j2.xml) now looks like that:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><Configuration monitorInterval="10">

        <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"/>
                </Console>

                <!-- Rolling file appender -->
                <RollingFile fileName="${sys:openhab.logdir}/openhab.log" filePattern="${sys:openhab.logdir}/openhab.log.%i.gz" name="LOGFILE">
                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                        <Policies>
                                <OnStartupTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="7"/>
                </RollingFile>

                <!-- Event log appender -->
                <RollingRandomAccessFile fileName="${sys:openhab.logdir}/events.log" filePattern="${sys:openhab.logdir}/events.log.%i.gz" name="EVENT">
                        <RegexFilter regex=".*_MainInputLine.*" onMatch="DENY" onMismatch="NEUTRAL"/>
                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                        <Policies>
                                <OnStartupTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="7"/>
                </RollingRandomAccessFile>

I hope that helps others,
Thanks Matze & Rich

I’m doing the same:
Some item events that are not relevant (especially the power change) I exclude from logging, but all the others I want to see in the log file.

Of cause there is no true or false, therefore we all can configure it as we need :wink: