[HELP] How do I configure a separate logfile for the ZWAVE binding

I have recently migrated onto OH3 and trying to get everything setup in a similar way to how my OH2 setup was.

How do I configure log4j2.xml so that the Z-Wave binding logs in sent to their own file. I’ve tried the config below, but that’s not worked as I expect. Although the logfile is created all of the logging is still going to openhab.log

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


<!-- Z-Wave logger -->
<Logger additivity="false" level="DEBUG" name="org.openhab.binding.zwave">
     <AppenderRef ref="ZWAVE"/>
</Logger>

Can you post an example of what you are seeing in logs?

Your config will only send DEBUG to new files.

EDIT: Also check you don’t have a duplicate entry.

All logging is going to openhab.log. Where as I want all of the output from the Z-Wave binding to go into the zwave.log.

I get that. But it would be helpful to see an example of the logs that you want redirected.

I have that set-up. The only difference I can see is this; ( I originally copied from the the github Zwave documentation.

<!-- Zwave custom file appender -->
        <RollingRandomAccessFile fileName="${sys:openhab.logdir}/zwave.log" filePattern="${sys:openhab.logdir}/zwave.log.%i" name="ZWAVE">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
            <Policies>
                <OnStartupTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="16 MB"/>
            </Policies>
        </RollingRandomAccessFile>
2021-08-28 17:56:06.974 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Checking TID 526: (Callback 65)
2021-08-28 17:56:06.974 [DEBUG] [.serialmessage.ZWaveCommandProcessor] - Callback match!
2021-08-28 17:56:06.974 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Correlated to TID 526: callback 65
2021-08-28 17:56:06.974 [DEBUG] [ve.internal.protocol.ZWaveController] - Incoming Message: Message: class=SendData[19], type=Request[0], dest=0, callback=65, payload=41 00 00 0E
2021-08-28 17:56:06.975 [DEBUG] [l.serialmessage.SendDataMessageClass] - NODE 68: SendData Request. CallBack ID = 65, Status = Transmission complete and ACK received(0)
2021-08-28 17:56:06.975 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: resetResendCount initComplete=true isDead=false
2021-08-28 17:56:06.975 [DEBUG] [nal.protocol.ZWaveTransactionManager] - TID 526: Advanced to WAIT_DATA
2021-08-28 17:56:06.975 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 68: TID 526: Transaction not completed
2021-08-28 17:56:06.975 [DEBUG] [nal.protocol.ZWaveTransactionManager] - ZWaveReceiveThread queue empty
2021-08-28 17:56:06.975 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Transaction SendNextMessage 1 out at start. Holdoff false.
2021-08-28 17:56:07.116 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: WakeupTimerTask 3 Messages waiting, state DONE
2021-08-28 17:56:07.616 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: WakeupTimerTask 3 Messages waiting, state DONE
2021-08-28 17:56:07.617 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: No more messages, go back to sleep
2021-08-28 17:56:07.617 [DEBUG] [commandclass.ZWaveWakeUpCommandClass] - NODE 68: Creating new message for application command WAKE_UP_NO_MORE_INFORMATION
2021-08-28 17:56:07.617 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: SECURITY not supported
2021-08-28 17:56:07.618 [DEBUG] [ng.zwave.internal.protocol.ZWaveNode] - NODE 68: Command Class COMMAND_CLASS_WAKE_UP is NOT required to be secured
2021-08-28 17:56:07.618 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 68: sendTransaction org.openhab.binding.zwave.internal.protocol.transaction.ZWaveCommandClassTransactionPayload@5b790698
2021-08-28 17:56:07.618 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 68: Bump transaction 545 priority from Immediate to Immediate
2021-08-28 17:56:07.618 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 68: Adding to device queue
2021-08-28 17:56:07.618 [DEBUG] [nal.protocol.ZWaveTransactionManager] - NODE 68: Added 545 to queue - size 68
2021-08-28 17:56:07.619 [DEBUG] [nal.protocol.ZWaveTransactionManager] - Transaction SendNextMessage 1 out at start. Holdoff false.

I also use

<RollingRandomAccessFile

I appended my custom appenders and loggers at the end of my log4j2.xml file, just above the block. That didn’t work. What worked for me was to add my custom appenders within the tags and custom loggers with the . Right or wrong, it started working.

I’ve tried all the combinations mentioned and still no luck. Can someone please provide me with a working version of their log4j2.xml file?

Here’s mine.

<?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>

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

                <!-- Rolling file appender -->
                <RollingFile fileName="${sys:openhab.logdir}/openhab.log" filePattern="${sys:openhab.logdir}/openhab.log.%i" 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>
                </RollingFile>

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

                <!-- Audit file appender -->
                <RollingRandomAccessFile fileName="${sys:openhab.logdir}/audit.log" filePattern="${sys:openhab.logdir}/audit.log.%i" name="AUDIT">
                        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
                        <Policies>
                                <OnStartupTriggeringPolicy/>
                                <SizeBasedTriggeringPolicy size="8 MB"/>
                        </Policies>
                </RollingRandomAccessFile>

                <!-- OSGi appender -->
                <PaxOsgi filter="*" name="OSGI"/>
        </Appenders>

        <Loggers>
                <!-- Root logger configuration -->
                <Root level="WARN">
                        <AppenderRef ref="LOGFILE"/>
                        <AppenderRef ref="OSGI"/>
                </Root>

                <!-- Karaf Shell logger -->
                <Logger level="OFF" name="org.apache.karaf.shell.support">
                        <AppenderRef ref="STDOUT"/>
                </Logger>

                <!-- Security audit logger -->
                <Logger additivity="false" level="INFO" name="org.apache.karaf.jaas.modules.audit">
                        <AppenderRef ref="AUDIT"/>
                </Logger>

                <!-- openHAB specific logger configuration -->

                <Logger level="INFO" name="org.openhab"/>

                <!-- Zwave custom logger -->
                <Logger additivity="false" level="DEBUG" name="org.openhab.binding.zwave">
                        <AppenderRef ref="ZWAVE"/>
                </Logger>

                <Logger level="ERROR" name="openhab.event.ItemStateEvent"/>
                <Logger level="ERROR" name="openhab.event.ItemAddedEvent"/>
                <Logger level="ERROR" name="openhab.event.ItemRemovedEvent"/>
                <Logger level="ERROR" name="openhab.event.ItemChannelLinkAddedEvent"/>
                <Logger level="ERROR" name="openhab.event.ItemChannelLinkRemovedEvent"/>
                <Logger level="ERROR" name="openhab.event.ChannelDescriptionChangedEvent"/>
                <Logger level="ERROR" name="openhab.event.ThingStatusInfoEvent"/>
                <Logger level="ERROR" name="openhab.event.ThingAddedEvent"/>
                <Logger level="ERROR" name="openhab.event.ThingUpdatedEvent"/>
                <Logger level="ERROR" name="openhab.event.ThingRemovedEvent"/>
                <Logger level="ERROR" name="openhab.event.InboxUpdatedEvent"/>
                <Logger level="ERROR" name="openhab.event.RuleStatusInfoEvent"/>
                <Logger level="ERROR" name="openhab.event.RuleAddedEvent"/>
                <Logger level="ERROR" name="openhab.event.RuleRemovedEvent"/>
                <Logger level="ERROR" name="openhab.event.StartlevelEvent"/>
                <Logger level="ERROR" name="openhab.event.AddonEvent"/>

                <Logger additivity="false" level="INFO" name="openhab.event">
                        <AppenderRef ref="EVENT"/>
                        <AppenderRef ref="OSGI"/>
                </Logger>

                <Logger level="ERROR" name="javax.jmdns"/>
                <Logger level="ERROR" name="org.jupnp"/>

                <!-- This suppresses all Maven download issues from the log when doing feature installations -->
                <!-- as we are logging errors ourselves in a nicer way anyhow. -->
                <Logger level="ERROR" name="org.ops4j.pax.url.mvn.internal.AetherBasedResolver"/>

                <!-- Filters known issues of pax-web (issue link to be added here). -->
                <!-- Can be removed once the issues are resolved in an upcoming version. -->
                <Logger level="OFF" name="org.ops4j.pax.web.pax-web-runtime"/>

                <!-- Filters known issues of lsp4j, see -->
                <!-- https://github.com/eclipse/smarthome/issues/4639 -->
                <!-- https://github.com/eclipse/smarthome/issues/4629 -->
                <!-- https://github.com/eclipse/smarthome/issues/4643 -->
                <!-- Can be removed once the issues are resolved in an upcoming version. -->
                <Logger level="OFF" name="org.eclipse.lsp4j"/>

                <!-- Filters warnings for events that could not be delivered to a disconnected client. -->
                <Logger level="ERROR" name="org.apache.cxf.jaxrs.sse.SseEventSinkImpl"/>

                <!-- Filters known issues of KarServiceImpl, see -->
                <!-- https://github.com/openhab/openhab-distro/issues/519#issuecomment-351944506 -->
                <!-- Can be removed once the issues are resolved in an upcoming version. -->
                <Logger level="ERROR" name="org.apache.karaf.kar.internal.KarServiceImpl"/>

                <!-- Filters warnings about unavailable ciphers when JCE is not installed, see -->
                <!-- https://github.com/openhab/openhab-distro/issues/999 -->
                <Logger level="ERROR" name="org.apache.karaf.shell.ssh.SshUtils"/>

                <!-- Filters known issues of javax.mail, see -->
                <!-- https://github.com/openhab/openhab-addons/issues/5530 -->
                <Logger level="ERROR" name="javax.mail"/>

                <!-- Filters disconnection warnings of the ChromeCast Java API, see -->
                <!-- https://github.com/openhab/openhab-addons/issues/3770 -->
                <Logger level="ERROR" name="su.litvak.chromecast.api.v2.Channel"/>

                <!-- Added by Karaf to prevent debug logging loops, see -->
                <!-- https://issues.apache.org/jira/browse/KARAF-5559 -->
                <Logger level="WARN" name="org.apache.sshd"/>
                <Logger level="INFO" name="org.openhab.binding.zwave"/>
        </Loggers>

</Configuration>

Try remove the duplicate zwave logged line… lat one.

Sorted, topman @Mark_VG