title: logback.xml in classpath getting executed along with logging.config Environment argument spring boot
body: <p>I have a spring boot project(version 1.3.6) and i have added logback.xml to the project. On creating an executable jar, the logback.xml is getting included in the jar and also working as expected. As the development is done on a windows system, so <strong>logback.xml in classpath</strong> adds the logs to file at path <strong>F:/application/logs/abc.log.</strong></p>
  
  <p>But on deployment of the jar on unix server, i want to provide logback.xml configuration from external file with a different path for logging file say <strong>(/opt/logs/abc.log)</strong>. I used -Dlogging.config argument while executing my jar file to provide the external logback.xml configuration file as below.</p>
  
  <pre><code>java -Dlogging.config=/path/to/logback.xml -jar ABC.jar
  </code></pre>
  
  <p>On running the above command, the logs are getting created successfully at <strong>/opt/logs/abc.log</strong> as per the external file configuration but the issue is that <strong>F:/application/logs/abc.log</strong> directory structure also gets created with a 0 byte file though no logging is being done in this.</p>
  
  <p>So if i am running my application from say /local directory on the server, then the below directories are getting created.</p>
  
  <pre><code>/local/F:/application/logs/abc.log
  </code></pre>
  
  <p>My question is how can we avoid the classpath log file directory structure(<strong>/local/F:/application/logs/abc.log</strong>) from getting created if external logback.xml configuration is used. </p>
  
  <p>My logback.xml is below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration debug="false"&gt;
  &lt;appender name="ROLLINGFILE"
      class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
      &lt;file&gt;F:/FRF/logs/iqcx-ticketing.log&lt;/file&gt;
      &lt;append&gt;true&lt;/append&gt;
      &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
          &lt;fileNamePattern&gt;F:/FRF/logs/iqcx-ticketing-%d{yyyy-MM}.%i.zip
          &lt;/fileNamePattern&gt;
          &lt;maxHistory&gt;10&lt;/maxHistory&gt;
          &lt;timeBasedFileNamingAndTriggeringPolicy
              class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
              &lt;maxFileSize&gt;20MB&lt;/maxFileSize&gt;
          &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
      &lt;/rollingPolicy&gt;
      &lt;encoder&gt;
          &lt;pattern&gt;%date{ISO8601} [%thread] - %-5level %logger %X - %msg%n
          &lt;/pattern&gt;
      &lt;/encoder&gt;
  &lt;/appender&gt;
  &lt;root&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/root&gt;
  &lt;logger name="iqcxLogger" level="info"&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/logger&gt;
  &lt;logger name="org.springframework" level="info" additivity="false"&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/logger&gt;
  &lt;logger name="org.mybatis.spring" level="info" additivity="false"&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/logger&gt;
  &lt;logger name="org.hibernate.validator" level="info" additivity="false"&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/logger&gt;
  &lt;logger name="org.apache.commons.beanutils" level="info" additivity="false"&gt;
      &lt;appender-ref ref="ROLLINGFILE" /&gt;
  &lt;/logger&gt;
  
  &lt;/configuration&gt;
  </code></pre>