title: logback appenders fail for scope= "context" but not scope= "system"
body: <p>I am trying out externalization of <code>logback-spring.xml</code> for my Springboot app.
  The <code>logback-spring.xml</code> file appends logs to two appenders, file appender and logstash appender.</p>
  <p>This file includes the externalized <code>logback-external.yml</code> file. Both the <code>logback-spring.xml</code> and the included file logback-external.yml are scanned for changes periodically as shown below.</p>
  <p>A few of the variables which are application specific are fetched from <code>application.yml</code> through <code>&lt;springProperty&gt;</code>.
  For <code>scope = “context”</code> or <code>scope= “local”</code> or <code>scope= “system”</code> the <code>&lt;springProperty&gt;</code> variables come as <code>‘logstash_port_IS_UNDEFINED’</code> (see logs snapshot) and all the appenders fail.</p>
  <p>However, for <code>scope= “system”</code> there is a catch. As mentioned in the logback <a href="http://logback.qos.ch/manual/configuration.html#scopes" rel="nofollow noreferrer">doc</a>, <em>“property with system scope is inserted into the JVM's system properties and lasts as long as the JVM or until it is cleared”</em>, it seems that the logback appenders continue to work with the old working values for these variables.</p>
  <p>Anybody else who has tried fetching application-specific logging parameters into logback-spring.xml file through  and faced a smilar issue while having auto scan enabled? Can I bank on scope= “system” for implementing externalization and auto-scanning of logback?</p>
  <p><strong>logback-spring.xml</strong></p>
  <pre><code> &lt;configuration  debug=&quot;true&quot; scan=&quot;true&quot; scanPeriod=&quot;15 seconds&quot;&gt;
      &lt;property resource=&quot;application.yml&quot; /&gt;
      &lt;springProperty scope=&quot;system&quot; name=&quot;logstash_host&quot;
          source=&quot;myapp.logging.logstash.host&quot; /&gt;
      &lt;springProperty scope=&quot;system&quot; name=&quot;logstash_port&quot;
          source=&quot;myapp.logging.logstash.port&quot; /&gt;
      &lt;springProperty scope=&quot;system&quot; name=&quot;base_log_dir&quot;
          source=&quot;base_log&quot; /&gt;
      &lt;springProperty  scope=&quot;system&quot; name=&quot;app_name&quot;
          source=&quot;spring.application.name&quot; /&gt;
      &lt;springProperty  scope=&quot;system&quot; name=&quot;app_port&quot;
          source=&quot;server.port&quot;/&gt;
      &lt;springProperty scope=&quot;system&quot; name=&quot;max_history&quot;
          source=&quot;logback.max_history_size&quot; /&gt;
      &lt;springProperty scope=&quot;system&quot; name=&quot;max_log_file_size&quot;
          source=&quot;max_log_size&quot; /&gt;
      
      &lt;include optional=&quot;false&quot;
          file=&quot;external-logback-file-location/logback-external.xml&quot; /&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p><strong>logback-external.yml</strong></p>
  <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;included&gt;
       
      &lt;appender name=&quot;FILE-ROLLING-ALL&quot;
          class=&quot;ch.qos.logback.core.rolling.RollingFileAppender&quot;&gt;
          &lt;filter class=&quot;ch.qos.logback.core.filter.EvaluatorFilter&quot;&gt;
              &lt;evaluator
                  class=&quot;ch.qos.logback.classic.boolex.OnMarkerEvaluator&quot;&gt;
                  &lt;marker&gt;metrics&lt;/marker&gt;
              &lt;/evaluator&gt;
              &lt;onMatch&gt;DENY&lt;/onMatch&gt;
          &lt;/filter&gt;
          &lt;rollingPolicy
              class=&quot;ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy&quot;&gt;
              &lt;fileNamePattern&gt;${base_log_dir}/${app_name}/${app_name}_-%d{yyyy-MM-dd}.%i.log
              &lt;/fileNamePattern&gt;
              &lt;maxFileSize&gt;${max_log_file_size}&lt;/maxFileSize&gt;
              &lt;maxHistory&gt;${max_history}&lt;/maxHistory&gt;
              &lt;!---other rolling specific policies here ----&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level
                  %logger{36}.%M [%line] - %msg%n
              &lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
  &lt;appender name=&quot;LOGSTASH&quot;
          class=&quot;net.logstash.logback.appender.LogstashTcpSocketAppender&quot;&gt;
          &lt;destination&gt;${logstash_host}:${logstash_port}&lt;/destination&gt;
          &lt;encoder charset=&quot;UTF-8&quot;
              class=&quot;net.logstash.logback.encoder.LogstashEncoder&quot;&gt;           
              &lt;customFields&gt;
              {               
                      &quot;custom-field&quot;:&quot;custom-field-value&quot;
              }
              &lt;/customFields&gt;
          &lt;/encoder&gt;
  &lt;/appender&gt;
      &lt;root level=&quot;info&quot;&gt;
          &lt;appender-ref ref=&quot;FILE-ROLLING-ALL&quot;/&gt;
          &lt;appender-ref ref=&quot;LOGSTASH&quot; /&gt;
      &lt;/root&gt;
      &lt;!-- in the absence of the class attribute, assume ch.qos.logback.core.hook.DefaultShutdownHook --&gt;
      &lt;shutdownHook
          class=&quot;ch.qos.logback.core.hook.DelayingShutdownHook&quot; /&gt;
  
  &lt;/included&gt;
  </code></pre>
  <p><strong>Error Logs From Logback</strong></p>
  <pre><code>22:37:02,388 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@4c9c7665 - Failed to invoke valueOf{} method in class [ch.qos.logback.core.util.FileSize] with value [max_log_file_size_IS_UNDEFINED]
  22:37:02,388 |-WARN in ch.qos.logback.core.joran.util.PropertySetter@4c9c7665 - Failed to set property [maxFileSize] to value &quot;max_log_file_size_IS_UNDEFINED&quot;.  ch.qos.logback.core.util.PropertySetterException: Conversion to type [class ch.qos.logback.core.util.FileSize] failed.
      at ch.qos.logback.core.util.PropertySetterException: Conversion to type [class ch.qos.logback.core.util.FileSize] failed.
      
      22:37:02,389 |-WARN in ch.qos.logback.core.joran.util.PropertySetter@99ee192 - Failed to set property [maxHistory] to value &quot;max_history_IS_UNDEFINED&quot;.  ch.qos.logback.core.util.PropertySetterException: Conversion to type [int] failed. 
      
      22:37:02,391 |-ERROR in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@945654245 - maxFileSize property is mandatory.
      
      Caused by: java.lang.IllegalArgumentException: Invalid destination 'logstash_host_IS_UNDEFINED:logstash_port_IS_UNDEFINED': unparseable value (expected format 'host[:port]').
      at  at net.logstash.logback.appender.destination.DestinationParser.parse(DestinationParser.java:62)
      at  at net.logstash.logback.appender.AbstractLogstashTcpSocketAppender.addDestination(AbstractLogstashTcpSocketAppender.java:892)
      at  ... 23 common frames omitted
  22:37:02,395 |-ERROR in net.logstash.logback.appender.LogstashTcpSocketAppender[LOGSTASH] - No destination was configured. Use &lt;destination&gt; to add one or more destinations to the appender
  </code></pre>