Suppress (error/warn) messages from Binding in logfile

Hi,

I’m using the Sony Binding but my TV is not powered 24/7 (because the Sony TVs have a ridiculous standyby power management and use up to 20W).

Of course the binding produces an connection error which fills my openhab.log and makes it difficult to read and produces a large filesize. Is there any way to suppress these error-messages?

Warning messages start like this:

2021-08-13 12:04:12.478 [WARN ] [ache.cxf.phase.PhaseInterceptorChain] - Interceptor for {http://192.168.178.77/sony/guide}WebClient has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:67) ~[bundleFile:1.0.9]

Thanks for your help!

Better than suppression

A method to manage ‘broken’ Things and retries by disable/enable

Hi,

thanks for the links. Wasn’t able to find them. I’m not quite there yet, though… I added the following to log4j2.xml:

		<!-- Sony appender -->
                <RollingRandomAccessFile append="true" fileName="${sys:openhab.logdir}/sony.log" filePattern="${sys:openhab.logdir}/sony.log.%i" immediateFlush="true" name="SONY">
                        <PatternLayout>
                                <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-50.50c] - %m%n</Pattern>
                        </PatternLayout>
                        <Policies>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="8"/>
                </RollingRandomAccessFile>
<!-- Sonyr -->

and

	<Logger additivity="false" level="TRACE" name="org.openhab.binding.gpstracker">
            <AppenderRef ref="SONY"/>
        </Logger>

I also tried:

	<Logger additivity="false" level="TRACE" name="ache.cxf.phase.PhaseInterceptorChain">
            <AppenderRef ref="SONY"/>
        </Logger>

Both did not work after restart. I’m lost and have no idea where to start or how to debug. Sorry and thanks for your help

You also have to set the level correctly as far as I know.

I also tried it with level=WARN… still noch success to redirect the message. :frowning: I’m out of ideas. Does anyone have an idea what to add to the xml?
Thanks a lot!

Did you set the debug level via the Karaf consol?

This appends a line to the log4j2.xml file something like:

		<Logger level="WARN" name="ache.cxf.phase.PhaseInterceptorChain"/>

This will conflict with the changes you made and needs to be removed.

I had this issue when trying to redirect messages and eventually started with a default .xml file and worked from there.

Hi,

no, I didn’t set the debug level and the entry you mentioned is not in the xml.
I attached my xml that I’m using atm. Maybe someone can see my mistake…

Additions I made are in 35-45 and 96-101.

Thanks a lot. Logging is really complicated to configure…

log4j2.xml (6.1 KB)
.

Maybe try with just the one Logger entry? So eliminate one of the following:

		<Logger additivity="false" level="WARN" name="org.openhab.binding.sony">
            <AppenderRef ref="SONY"/>
        </Logger>
		<Logger additivity="false" level="WARN" name="ache.cxf.phase.PhaseInterceptorChain">
            <AppenderRef ref="SONY"/>
        </Logger>

Do you get any errors in the wrapper.log?
Does the sony.log file get created?

As soon as I add your appender to my log4j2.xml the sony.log file gets created. No restart required.

		<!-- GPSTracker appender -->
                <RollingRandomAccessFile append="true" fileName="${sys:openhab.logdir}/sony.log" filePattern="${sys:openhab.logdir}/sony.log.%i" immediateFlush="true" name="SONY">
                        <PatternLayout>
                                <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-50.50c] - %m%n</Pattern>
                        </PatternLayout>
                        <Policies>
                                <SizeBasedTriggeringPolicy size="16 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="8"/>
                </RollingRandomAccessFile>
        <!-- GPS Tracker -->

So i would guess that part is fine.

Don’t use the Sony Binding, so can’t test that… However using the same syntax with my Shelly Binding it works 100% with the following:

		<Logger additivity="false" level="DEBUG" name="org.openhab.core.model.script.shelly_em">
            <AppenderRef ref="SONY"/>
        </Logger>

So maybe you can try the attached log4j2.xml and just modify the Logger to suite your needs? Hope that helps?
log4j2.xml (6.3 KB)

Another thing to check… If you issue something like the following from Karaf Console:

log:set WARN org.openhab.core.model.script.RandomTest123

Do you see the relevant logger added to log4j2.xml?

		<Logger level="ERROR" name="org.apache.sshd"/>
		<Logger level="WARN" name="org.openhab.core.model.script.Hue"/>
		<Logger level="WARN" name="org.openhab.core.model.script.Hue123"/>
		<Logger level="WARN" name="org.openhab.core.model.script.RandomTest123"/>
	</Loggers>

</Configuration>

If not I suspect the issue is in the userdata\etc\org.ops4j.pax.logging.cfg, meaning that the log4j2.xml is not even being looked at.

2 Likes

Hi,
thanks for the long reply. I still can’t get it to work.

Step by step:

  • a sony.log is created as soon as I save the log4j2.xml
  • but it stays empty no matter what it do… i changed the permissions to 0777 just in case
  • when I issue log: set WARN … in the console it does get added in the log4j2.xml so I assume everything else is correct
  • I don’t have a wrapper.log, the file does not exist for me

I also tried your file and replaced the part in [ ] with something from my log, but still nothing appears in the sony.log.

To make things clear. If I have a line like this in the openhab.log:

2021-08-25 18:01:26.798 [INFO ] [openhab.core.model.script.motion.rules] - Bewegung detektiert

and I would like it to go into sony.log then in log4j2.xml I’d need:

<Logger additivity="false" level="INFO" name="openhab.core.model.script.motion.rules">
  <AppenderRef ref="SONY"/>
</Logger>

Even this does not work correctly for me, the sony.log stays empty… I’m still using your log4j2.xml example. Do you have any more ideas? I’d really love to solve that problem.

Thanks a lot for your support!

edit: finally I got it working! The name was incorrect because it’s shortened automatically. If I use:

<Logger additivity="false" level="ERROR" name="org.apache.cxf.phase">

it gets suppressed and then everythin else also works including redirecting into sony.log
THANKS A LOT!

Hi.

I am out of ideas. But it seems that you have changed direction somewhat?

The log entry you have sent now looks like it is generated by a rule? Can you share the rule?

What looks odd to me is the .motion.rule part of:

2021-08-25 18:01:26.798 [INFO ] [openhab.core.model.script.motion.rules] - Bewegung detektiert

As far as I know if your rule log line was:

logDebug("motion", "TEXT... ")

The log entry would look something like:

18:01:26.798 [DEBUG ] [openhab.core.model.script.motion] - TEXT...

so not sure where the ````.motion.rules``` comes from?

Have you tried using logDebug and then something like:

log:set DEBUG org.openhab.core.model.script.motion
1 Like

Just a reminder that ache.cxf.phase.PhaseInterceptorChain is not the full name of the package producing the warning,it’s truncated. Shall we guess at apache?

1 Like

Yes, thanks! Of course that was the mistake. In my edit above I also realized it but my edit overlapped with your answers.

If I use:

<Logger additivity="false" level="ERROR" name="org.apache.cxf.phase">

everything works. I simply didn’t realize it was truncated… silly mistake.

Thanks for your support!

1 Like