[logback-dev] [JIRA] (LOGBACK-1309) No autoscaning for changed logback.xml when using http-URI for config file

QOS.CH (JIRA) noreply-jira at qos.ch
Sun Jun 4 21:05:00 CEST 2017


Jørgen Ringen created LOGBACK-1309:
--------------------------------------

             Summary: No autoscaning for changed logback.xml when using http-URI for config file
                 Key: LOGBACK-1309
                 URL: https://jira.qos.ch/browse/LOGBACK-1309
             Project: logback
          Issue Type: Bug
          Components: logback-core
    Affects Versions: 1.1.11
         Environment: MacOS, Spring Boot 1.5.3.RELEASE, Java 8
            Reporter: Jørgen Ringen
            Assignee: Logback dev list


Here is my logback.xml:
{code:java}
<configuration scan="true" scanPeriod="10 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
 <pattern>
  %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
 </pattern>
 </encoder>
 </appender>
 <logger name="com.acme" level="DEBUG" additivity="false">
  <appender-ref ref="STDOUT"/>
 </logger>
 <root level="INFO">
  <appender-ref ref="STDOUT"/>
 </root>
</configuration>{code}
Notice that scan=true and scanPeriod=10 seconds.

I host my logback.xml file on a remote server and I use Spring Boot to instantiate logback. Spring boot takes the property -Dlogging.config=[http://acme.com:1337/logback.xml] and passes this to: ch.qos.logback.core.joran.GenericConfigurator#doConfigure(java.net.URL)

Logback looks up the config-file from the remote url, instantiates the config, and everything seems fine, except for autoscanning.

I see that logback uses the class ch.qos.logback.core.joran.spi.ConfigurationWatchList to keep track of files with autoscanning and a class called ch.qos.logback.classic.joran.ReconfigureOnChangeTask to do the periodic polling.

When a URI is added to the watch-list, the following code is executed:
{code:java}
ch.qos.logback.core.joran.spi.ConfigurationWatchList#addAsFileToWatch
private void addAsFileToWatch(URL url) {
    File file = convertToFile(url);
    if (file != null) {
        fileWatchList.add(file);
        lastModifiedList.add(file.lastModified());
    }
}

ch.qos.logback.core.joran.spi.ConfigurationWatchList#convertToFile
File convertToFile(URL url) {
    String protocol = url.getProtocol();
    if ("file".equals(protocol)) {
        return new File(URLDecoder.decode(url.getFile()));
    } else {
        addInfo("URL [" + url + "] is not of type file");
        return null;
    }
}


{code}
Notice that theres a check to ensure that the URL-protocol is "file". This check fails for URL's with http-protocol, so no autoscanning is performed on the configuration-file.

Is this expected behaviour? If so, why, and is it possible to create a feature-request for autoscanning on http-uri's?



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the logback-dev mailing list