[logback-dev] [JIRA] Updates for LOGBACK-1731: <include> element only seems to be substituting variables which are on scope "system"

logback developers list logback-dev at qos.ch
Mon Apr 3 11:19:00 CEST 2023


logback / LOGBACK-1731 [Open]
<include> element only seems to be substituting variables which are on scope "system"

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

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

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

Terry van der Griend created this issue on 03/Apr/23 11:07

Summary:              <include> element only seems to be substituting variables which are on scope "system"
Issue Type:           Bug
Affects Versions:     1.4.6
Assignee:             Logback dev list
Components:           logback-core
Created:              03/Apr/23 11:07
Environment:          Spring boot application 3.x.x
Labels:               include substitution variable
Priority:             Major
Reporter:             Terry van der Griend
Description:
  {code:java}
  // code placeholder
  {code}
  We are migration from Logback 1.2.11 to 1.4.7 and stumbled upon on an issues regarding the <include file=""> element.
  
  When the <include file=""> element is used in combination with a <variable> as its value, it is not able to include the file when the variable is not on the scope "system".
  
  Logback will keep trying to add the file to the ConfigurationWatchListUtil with the "_IS_UNDEFINED" replacement.
  h3. Our case:
  
  We are using logback via spring to load a file, this is done based on the configured file location using a <springProperty>. When investigating further we have noticed that this issue is not unique to the <springProperty> but also includes the <variable> and <property> elements.
  h3. Reproduction configuration:
  
   
  {code:java}
  <configuration debug="true">
    <variable name="include" value="<other file location>.xml"/>
    <include file="${include}"/>
  </configuration> {code}
  When using the provided configuration the "include" variable is not substituted in the file element. It tries to substitute it, but it is not able to resolve its value.
  
   
  
  However when using the following configuration:
  {code:java}
  <configuration debug="true">
   <variable scope="system" name="include" value="<other file location>.xml"/>
   <include file="${include}"/> 
  </configuration>  {code}
  Now the file will be included. Using any other scope then "system" will result into an "_IS_UNDEFINED" file inclusion.
  h3. Workaround:
  
  For now we have found a workaround which we are not very keen on to keep using. By offloading the original variable onto a system scoped variable we are able to include the file. This does mean that we are exposing unwanted variable on the system properties which we would rather not.
  
  Offloading a <springProperty> to a <variable> with the system scope also seems to work.


==============================
 This message was sent by Atlassian Jira (v9.6.0#960000-sha1:a3ee8af)



More information about the logback-dev mailing list