openHAB - Filtering event logs

Thanks for the grep idea… I knew about it, but I didn’t think of it.
log:display | grep -v... works, but log:tail | grep -v ... does not… Weird…
But even if it works, looks kinda tedious to enter the command every time I’m watching the console.

I tried setting the console logger with the RegexFilter, but it’s not working - Console appender not used by default (see log4j2.rootLogger.appenderRefs)

# Appenders configuration

# Console appender not used by default (see log4j2.rootLogger.appenderRefs)
log4j2.appender.console.type = Console = STDOUT
log4j2.appender.console.layout.type = PatternLayout
log4j2.appender.console.layout.pattern = %d{HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n

log4j2.appender.console.filter.ignore.type = RegexFilter
log4j2.appender.console.filter.ignore.regex = .*(NAS|SystemStatus).*
log4j2.appender.console.filter.ignore.onMatch = DENY
log4j2.appender.console.filter.ignore.onMisMatch = ACCEPT
1 Like

After changing the file org.ops4j.pax.logging.cfg

What is the fastest way to activate it?
It’s obviously not read automatically like rules and such!?

EDIT: Never mind. openhab DOES reload it obviously automatically.
My cfg file was somehow messed up the first time I tried it…

Does anyone know how to filter openhab.log?

Would you just swap out system for event in the examples above??

Tried that. Doesn’t work.

OpenHAB - Filtering event logs shows for events.log but could be adapted to openhab.log. oops, that’s this thread. I guess I can’t help except to point out alternatives.

Log4j2 Sample Config shows how to shunt all the logs from a certain binding or part of oh to a separate file.

How to watch and look through logging shows both posix (Linux and Mac) as well as powershell ways to tail logs and filter what gets printed.


I thought I had a fix by using NEUTRAL instead of ACCEPT for the first filter, which seemed to work initially but that didn’t work out either. So back to using Marvin_Autonomous’ solution.

Did you ever figure this out for openhab.log ? I can’t seem to get this to work for that log file…

Kind of, what do you want to do?

I think I managed to figure something out. I could not get the filtering approach to work to filter out some recurring warning messages in the openhab log. I tried setting the root logger to ERROR and it took care of it. Not ideal but will avoid flooding my logs for now.

I am having the same problem trying to filter out Errors from the Openhab.log

This tutorial only seems to be for Events.log

I just want to stop these messages appearing in the openhab.log

> 2019-02-01 14:52:10.081 [ERROR] [sciani.connector.MyHomeJavaConnector] - Monitor connection problem. Attempting retry 2.
> 2019-02-01 14:52:10.081 [ERROR] [sciani.connector.MyHomeJavaConnector] - Monitor connection problem. Attempting retry 2.

In the file:
There is a section for each log file
Modify the section for openhab.log the same way as the examples above

This is what I’ve tried but it does not seem to work? Am I in the correct section

Rolling file appender

log4j2.appender.out.type = RollingRandomAccessFile = LOGFILE
log4j2.appender.out.fileName = ${openhab.logdir}/openhab.log
log4j2.appender.out.filePattern = ${openhab.logdir}/openhab.log.%i
log4j2.appender.out.immediateFlush = true
log4j2.appender.out.append = true
log4j2.appender.out.layout.type = PatternLayout
log4j2.appender.out.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.out.policies.type = Policies
log4j2.appender.out.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.out.policies.size.size = 16MB

#log enhancement
log4j2.appender.out.filter.btcino.type = RegexFilter
log4j2.appender.out.filter.btcino.regex = = .*Monitor connection problem*
log4j2.appender.out.filter.btcino.onMatch = DENY
log4j2.appender.out.filter.btcino.onMisMatch = ACCEPT

This is yours:

log4j2.appender.out.filter.btcino.regex = = .*Monitor connection problem*

This is the example:

log4j2.appender.event.filter.smappee.regex = .*power_smappee.*

See the difference?

1 Like

Yes I tried that one before but I assumed that is just filtering from the event.log because it did not work

And that?
= = ??


ah!! indeed… Does is work?

just testing!

Yes this works thanks for your help! I’m still not too clear on the regex pattern matching - I can’t find a good site that explains exactly how it works with wildcards but for now this is fine.

#log enhancement
log4j2.appender.out.filter.btcino.type = RegexFilter
log4j2.appender.out.filter.btcino.regex = .*connection problem.*
log4j2.appender.out.filter.btcino.onMatch = DENY
log4j2.appender.out.filter.btcino.onMisMatch = ACCEPT