title: SpringBoot with LogBack creating LOG_FILE_IS_UNDEFINED folder
body: <p>I am using SpringBoot with LogBack and I am trying to direct all log-statements of one specific package (here shown as "com.example.somepackagename") to a file. All other log statements should go to stdout.</p>
  
  <p>At first ran into the issue that during startup a file "LOG_FILE_IS_UNDEFINED" was created. I then googled on that issue (found e.g. <a href="https://github.com/spring-projects/spring-boot/issues/8675" rel="noreferrer">this on github</a> or <a href="https://stackoverflow.com/questions/25251983/springboot-with-logback-creating-log-path-is-undefined-folder">this on StackOverflow</a> and a few others), but none of the appends really solved the issue.</p>
  
  <p>Based on the misc. descriptions I came up with the below configuration using a logback-spring.xml-file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;property name="LOG_PATH" value="${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}" /&gt;
      &lt;property name="LOG_FILE" value="${LOG_FILE:-ts-msgs.log}" /&gt;
  
      &lt;include resource="org/springframework/boot/logging/logback/defaults.xml" /&gt;
      &lt;include resource="org/springframework/boot/logging/logback/file-appender.xml" /&gt;
  
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt;
              &lt;Pattern&gt;%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n&lt;/Pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="MSG_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;${LOG_PATH}/${LOG_FILE}&lt;/file&gt;
          &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt;
              &lt;Pattern&gt;%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%t] %-40.40logger{39} : %m%n%wex&lt;/Pattern&gt;
          &lt;/encoder&gt;
  
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
              &lt;!-- rollover daily --&gt;
              &lt;fileNamePattern&gt;${LOG_PATH}/archived/debug.%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
              &lt;timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"&gt;
                  &lt;maxFileSize&gt;10MB&lt;/maxFileSize&gt;
              &lt;/timeBasedFileNamingAndTriggeringPolicy&gt;
          &lt;/rollingPolicy&gt;
      &lt;/appender&gt;
  
      &lt;logger name="com.example.somepackagename" additivity="false" level="debug"&gt;
           &lt;appender-ref ref="MSG_LOG_FILE" /&gt;
      &lt;/logger&gt;
  
      &lt;logger name="org.springframework" additivity="false" level="info"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/logger&gt;
  
      &lt;root level="warn"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/root&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>With that I don't get a file called "LOG_FILE_IS_UNDEFINED" anymore but LogBack now always first creates an empty file "ts-msgs.log" in the working directory of the application before it creates a file with the same name in the temp-directory (where that file should go). So, somehow during initialization it already creates a file with the correct name but the correct path not being set, yet. In other words, the initialization order of Logback within SpringBoot seems broken (or at least not intuitive) and it seems impossible to avoid a first log-file being created before the correct path for the file-appender is being defined and applied.</p>
  
  <p>How can one prevent that first, initial and empty log file from being created? This is necessary, since the working directory is in general write-protected and the attempt to create a file there will lead to an exception (and typically the program being terminated).</p>
  
  <p>Any hints or suggestions?</p>
  
  <p>BTW: I already tried to rename that file to logback.xml (which seems to be processed earlier during SpringBoot startup) but that didn't solve the issue, so I kept the suggested filename.</p>