Suppress (error/warn) messages from Binding in logfile

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