when using vanila Spring boot 1.4.5 with the following logback configuration:

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>${LOG_FILE}</file>
    <encoder>
      <pattern>%logger{35} - %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="FILE" />
  </appender>

  <root level="INFO">
    <appender-ref ref="ASYNC" />
  </root>
</configuration>

and the following application.properties:

logging.file=/tmp/myapp.log

Empty file is being created in the name of LOG_FILE_IS_UNDEFINED. Looks like 2 async appenders are being created, one with LOG_FILE_IS_UNDEFINED as the file name and another one with the file name from the properties. The LOG_FILE_IS_UNDEFINED is stopped immediately and this is why the file is empty.

@regevbr

Comment From: philwebb

Have you tried using a logback-spring.xml file rather than logback.xml? I have a feeling that logback might be initializing itself before we can set the LOG_FILE property.

If that doesn't work, could you please share a small sample application that shows the problem?

Comment From: regevbr

We are using the logback-spring.xml file already and the issue still persists

Comment From: philwebb

@regevbr You have the same issue?

If that doesn't work, could you please share a small sample application that shows the problem?

Are you able to provide a sample?

Comment From: regevbr

Hi, Roi and I are working in the same team. We will provide a sample application as soon as we can.

Comment From: ezraroi

Hi, after changing the file to logback-spring.xml it is working fine! thanks

Comment From: pksinghus

I am having this problem with spring boot 1.5.2.RELEASE while using logback-spring.xml

application.properties -

logging.config=classpath:logback-spring.xml
logging.file=app.log

logback-spring.xml -

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_FILE}</file>
    <encoder class="extension of PatternLayoutEncoder">
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5}  - %msg%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>9</maxIndex>
    </rollingPolicy>
    <triggeringPolicy
            class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>10MB</maxFileSize>
    </triggeringPolicy>
</appender>

Comment From: philwebb

@pksinghus Try dropping the logging.config property, it shouldn't be needed if you're using logback-spring.xml. If that doesn't work please open a new issue and share a project that replicates the problem.

Comment From: stguitar

I really really hate to comment on a closed ticket, but I am not finding much info about this issue these days on the web that feels applicable to my application.

We're using spring boot 2.1.4, and I have the same setup as the previous post, but do not have the logging.config property set. We have a logback-spring.xml file in the project.

When I run this application, I get these files named LOG_FILE_IS_UNDEFINED that are being created. They are dated, as if they are rolling over after some period of time.

Going off the commentary above, I am not sure what else I should try to avoid this behavior.

Comment From: pksinghus

This happening because you have some spring cloud artifact in your pom. Remove it and this error will be gone. Don't include cloud unless you are integrating with cloud which you shouldn't because your Java app doesn't need to know where it is running.

Comment From: stguitar

Thanks for the quick reply!

Yes, that is indeed true. I am trying to use Zuul in this application. I am using Gradle btw, but my entries in the dependencies block has implementation 'org.springframework.cloud:spring-cloud-starter-netflix-zuul'.

I had also read on some other tickets that I should use the spring cloud BOM to manage this dependency, so I have the following in my build.gradle file as well:

ext {
    set('springCloudVersion', "Greenwich.SR1")
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

Are you suggesting that I remove all of this?

Comment From: pksinghus

Removing all cloud business resolved this issue for me. I wasn't using any of it. Some of it was getting transitively pulled.

Comment From: stguitar

cool, gotcha. Yea, sadly, I don't think that'd work for my application since I need to use Zuul, but thanks for the info! I am hoping I can find something else causing this...

Comment From: amounib

So, for us, we need the spring cloud components. Found that adding <include resource="org/springframework/boot/logging/logback/base.xml" /> right after the configuration tag at the top resolves the erroneous file generation

So our file starts

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml" />
    <appender name="JSON" class="ch.qos.logback.core.rolling.RollingFileAppender">

Comment From: DachengChen

this is my logback-spring.xml file and works, property should direcly after configuration

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <property name="LOG_FILE" value="/var/log/application.log"/>
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <include resource="org/springframework/boot/logging/logback/file-appender.xml" />
    <root level="INFO">
        <appender-ref ref="FILE" />
    </root>
</configuration> 

Comment From: shithanshu-beltech

In My case, it was a stupid mistake I commented logging.pattern.file, logging.file.name and when logback was parsed (logback didn't contain these details) after application .properties it wasn't able to find any pattern hence was throwing the error LOG_FILE_IS_UNDEFINEDLOG

Make sure you check your application properties and logback.xml (either of them should contain the configuration)

Comment From: youngledo

When I used bootstrap.yml, the problem still existed.

SpringBoot LOG_FILE_IS_UNDEFINED log file is being created in boot 1.4.5

Comment From: shithanshu-beltech

@youngledo Can you Share your logback-spring.xml file

Comment From: youngledo

@shithanshu-beltech Uploaded a sample code, you can directly run it to see

sample.zip

In addition, I found that adding this dependency can solve the problem of the sample project, but it still cannot solve my project problem.

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-bootstrap</artifactId>
        </dependency>

Comment From: shithanshu-beltech

@youngledo The logback is unable to understand if it needs to read those properties from bootstrap.yaml So while running the app you need to mark bootstrap.yml as config location

-Dspring.config.location=src/main/resources/bootstrap.yml Add this to your run argument and it will start working Let me know if you want to keep bootsrap.yml as different from application.properties