Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Level is changed with reload, without reload it doesn't work. #182

Closed
nedad opened this issue Aug 3, 2018 · 3 comments
Closed

Log Level is changed with reload, without reload it doesn't work. #182

nedad opened this issue Aug 3, 2018 · 3 comments
Assignees

Comments

@nedad
Copy link

nedad commented Aug 3, 2018

Hello,

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

# Properties in this file act as fallback values. They get overridden by specific ones dependent on the chosen flavor
root.loglevel=OFF

logback.xml

<configuration debug="true" scan="true" scanPeriod="2 seconds">

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

<?xml version="1.0"?>

<included>

<property value="OFF" name="root.level"/>

</included>

Regards,
Neda

@tony19 tony19 added the bug label Aug 5, 2018
@tony19 tony19 self-assigned this Aug 5, 2018
@tony19
Copy link
Owner

tony19 commented Aug 5, 2018

Bug in file-change detection

There's a bug in 1.1.1-12 that prevents <included> file-change detection from occurring, which blocks the scan feature you're seeking. Specifically, file-change detection is disabled if the main configuration URL (to the JAR resource of assets/logback.xml) cannot be determined, which is occurring because ContextInitializer is passing an InputStream to GenericConfigurator.doConfigure(InputStream), which does not set the main configuration URL, required for config-file change detection to proceed.

This will be fixed in the next release.

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">.

tony19 added a commit that referenced this issue Aug 6, 2018
The main config URL was not set when auto-config used assets/logback.xml,
so <configuration scan="true"> had no effect. This patch ensures the URL
is set by passing the URL to assets/logback.xml (instead of a stream
to it).

Fixes #182
@tony19 tony19 closed this as completed in 6a809b0 Sep 5, 2018
@tony19
Copy link
Owner

tony19 commented Sep 5, 2018

Fixed in 1.1.1-13

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the archived label Feb 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants