[solved] How to modify the log file with the proper logger name

Hi folks,

regarding https://github.com/openhab/openhab/issues/3243

I know the issue is not critical, but the message in the log is a bit annoying.

How can I set the logger level to “ERROR”? what is the right logger name?

I see only [.denon.internal.DenonConnector]

Thank you very much

Andrea

1 Like

By default the logger truncates the logger names. The full logger name will be:

org.openhab.binding.denon.internal.DenonConnector

I have now gotten into the habit of adding separate log files for each binding in the logback.xml file, here is an example for the Astro binding :-

   <appender name="ASTRO" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>logs/astro.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                    <!-- weekly rollover and archiving -->
                    <fileNamePattern>logs/astro-%d{yyyy-ww}.log.zip</fileNamePattern>
                    <!-- keep 30 days' worth of history -->
                    <maxHistory>30</maxHistory>
            </rollingPolicy>
            <encoder>
                    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%-30.30logger{36}:%-4line]- %msg%n</pattern>
            </encoder>
    </appender>

    <!-- Change DEBUG->TRACE for even more detailed logging -->
    <logger name="org.openhab.binding.astro" level="DEBUG" additivity="false">
            <appender-ref ref="ASTRO" />
    </logger>

I also have a separate log for all my automation / rules, you can create that like this :-

    <appender name="MYAUTOMATION" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <file>logs/myautomation.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                    <!-- weekly rollover and archiving -->
                    <fileNamePattern>logs/myautomation-%d{yyyy-ww}.log.zip</fileNamePattern>
                    <!-- keep 30 days' worth of history -->
                    <maxHistory>30</maxHistory>
            </rollingPolicy>
            <encoder>
                    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%-30.30logger{36}:%-4line]- %msg%n</pattern>
            </encoder>
    </appender>

    <!-- Change DEBUG->TRACE for even more detailed logging -->
    <logger name="org.openhab.model.script.myautomation" level="DEBUG" additivity="false">
            <appender-ref ref="MYAUTOMATION" />
    </logger>

Which you can then reference in your rules like this :-

logInfo("myautomation", "astro.rules - Item Sunset_Event received update ON")

Thank you guys, I appreciate your help on this.

@SupraWez that means I can debug a rule? :sunny:

Yes, you can add your own logging info into the rules to check that its functioning correctly.

but you see only the LogInfo, or even the reason, ie. why the rule is taking too long?

your example works only for scripts, or even for rules?

thanks again

Correct, you would need to place Loginfo statements in various stages throughout your scripts / rules, if you pick your logging locations you should be able to determine which step is causing the delay :wink:

Not yet checked which other files can be debugged like this.