Overide logback.xml for custom extension

This article guides overriding the logback.xml file for a custom extension. The purpose is to generate a separate log file for the custom extension, thereby preventing extension-related log flooding in the hivemq.log file. It is considered a best practice to maintain a distinct log for custom extensions, as it proves beneficial during the debugging process in cases of unexpected behavior.

 Instructions

  1. To create a distinct log file, navigate to and edit the logback.xml file located at /opt/hivemq/conf/. Follow the example below:

    1. <appender name="CUSTOM-EXT-LOG-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${hivemq.log.folder}/custom-extension.log</file> <append>true</append> <encoder> <pattern>%~24(%d)~ %msg%n%ex</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${hivemq.log.folder}/custom-extension-%i.log.gz</fileNamePattern> <minIndex>1</minIndex> <maxIndex>5</maxIndex> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <maxFileSize>100MB</maxFileSize> </triggeringPolicy> </appender> <logger name="<--YOUR EXTENSION CLASS NAME-->" level="INFO" additivity="false"> <appender-ref ref="CUSTOM-EXT-LOG-FILE"/> </logger>

      Note: Please make sure to use your extension class name for the logger’s name.

 Related articles