Logback doesn't change log level in runtime

463 Views Asked by At

I am using your com.github.tony19:logback-android:1.1.1-12 library.

After I change my Log Level in Property file, I expect that the Log Level is changed in runtime. But ist doesn't work.

Do you know what could be a Problem?

I have set scan=true and scanPeriod=2 seconds. I have every time after I set the change in properties file to restart the Android App. Because only in this way works.

logback.properties: 

root.loglevel=OFF

logback.xml

<include file="${EXT_DIR}/Download/de.hermes.alpha/assets/logbackincludedfile.xml"
    optional="true" />
<root level="${root.loglevel:-DEBUG}">
    <appender-ref ref="logcat" />
    <appender-ref ref="logstash" />
    <appender-ref ref="rollingLogFile" />
</root>

Regards, Neda

1

There are 1 best solutions below

0
On

scan feature broken in 1.1.1-12

There's currently a bug in 1.1.1-12 that prevents the file-change detection from occurring, which blocks the scan feature you're seeking. If you enable <configuration debug="true">, you should see this error message in LogCat:

Due to missing top level configuration file, automatic reconfiguration is impossible.

This will be fixed in the next release. (Tracked in logback-android Issue #182)

Only included files are scanned

Your comment below makes an incorrect assumption that files specified in <property> are scanned:

After I change my Log Level in Property file, I expect that the Log Level is changed in runtime.

The .properties file (included via <property file="...">) does not get scanned. In this case, only files from <include file="..."> are scanned periodically when <configuration scan="true">.