Redirect binding logs to file

Hi All

I am trying to redirect by GPSTRACKER Binding logs to a separate file to do some debugging.


  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
    • OS:Win 10 Pro
    • Java Runtime Environment:Zulu 11.43.55
    • openHAB version: OH 3.1 - SNAPSHOT

I have set org.openhab.binding.gpstracker to TRACE as follows:

log:set TRACE org.openhab.binding.gpstracker

org.openhab.binding.caddx                          | INFO
org.openhab.binding.gpstracker                     | TRACE
org.openhab.binding.harmony                        | INFO

I can also see logs when TRACE logs when running log:tail

18:19:29.356 [TRACE] [acker.internal.handler.TrackerHandler] - batteryLevel -> 51
18:19:29.356 [TRACE] [acker.internal.handler.TrackerHandler] - lastLocation -> <REDACT>
18:19:29.356 [TRACE] [acker.internal.handler.TrackerHandler] - lastReport -> 2021-03-13T18:19:27.000+0200

I have tried to make the following changes to the log4j2.xml file as found on the forum.

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

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

Also tried using “RollingFile” instead of “RollingGPS” - I read somewhere that they had to be distinct.
Full file as follows:

log4j2.xml (5.6 KB)

I have restarted OpenHab etc, but I still dont get a new log file…

Any suggestions?


So I managed to find a solution.

Had to replace my C:\openHAB\userdata\etc\org.ops4j.pax.logging.cfg with one that contains only:


Then added the following to my log4j2.xml

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

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

Hope this helps someone else.