[logback-dev] [JIRA] Updates for LOGBACK-1635: No way to override bundled logback.xml with local file

QOS.CH (JIRA) noreply-jira at qos.ch
Tue May 3 10:32:00 CEST 2022


logback / LOGBACK-1635 [Open]
No way to override bundled logback.xml with local file

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/LOGBACK-1635

==============================
 Issue created
------------------------------

Roland Tepp created this issue on 03/May/22 10:17 AM
Summary:              No way to override bundled logback.xml with local file
Issue Type:           Bug
Affects Versions:     1.3.0-alpha14
Assignee:             Logback dev list
Components:           logback-classic
Created:              03/May/22 10:17 AM
Environment:
  My environment:
  
   
Labels:               configuration default
Priority:             Minor
Reporter:             Roland Tepp
Description:
  The code that is responsible for loading default log configuration makes it awkward to bundle a default `logback.xml` configuration and have a way to override this by dropping `logback.xml` in the work directory of the application.
  
   
  
  I just took logback classic version `1.3.0-alpha14` for a test drive on a smallish project and after having configured the sane production defaults for the `logback.xml` in the bundled resources, found that I needed more verbose output.
  
  To my dissapointment, when I dropped a slightly modified copy in the work directory of the launched application, I did not see any change in the log ouytput, so I went and digged in to the Logback configuration resolution algorithm and to my horror, I found that files bundled in the classpath are strictly preferred over files provided in the work directory.
  
  The algorithm currently goes this way:
   # findConfigFileURLFromSystemProperties(myClassLoader{color:#cc7832}, {color}updateStatus){color:#cc7832};{color}
   ## Given {color:#6a8759}logback.configurationFile{color} system property
   ## try to load resource from url
   ## if not a url, try loading it from classpath
   ## if that does not succeed, try loading configuration from filesystem
   # getResource({color:#9876aa}TEST_AUTOCONFIG_FILE{color}{color:#cc7832}, {color}myClassLoader{color:#cc7832}, {color}updateStatus){color:#cc7832};{color}
   # getResource({color:#9876aa}AUTOCONFIG_FILE{color}{color:#cc7832}, {color}myClassLoader{color:#cc7832}, {color}updateStatus){color:#cc7832};{color}
  
  {{getResource}} is implemented as a call to {{ClassLoader.getResource(...)}}, so effectively, the only way to override logging configuration of the application at deployment time is by specifying a file: url in {color:#6a8759}logback.configurationFile{color} system property with exact path to the configuration file.
  
   
  
  The expected behavior would be to consult filesystem for configuration file before trying classpath. That way, the simplest way to override logging configuration would be just dropping a file in the file system and have logback pick that up at initialization time.
  
   


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)



More information about the logback-dev mailing list