How can I avoid Spring Boot Logback fail-fast when creating a file?

At startup, Logback tries to create / open log files. However, in the current version of Spring Boot, if the files cannot be opened, the application is closed.

This appears to be intentional behavior as shown in the SpringBoot git .

I would prefer to either use Tomcat logging by default, or disable logging altogether, but let my application continue to run. Since we need to deploy it in different environments and for a short lifetime, I would prefer not to configure the log path for each instance to be deployed.

However, I have not found any property in the Spring Boot or Logback settings that can allow me to do this.

Is there a way around this IllegalStateException

?

This is the startup error:

    java.lang.IllegalStateException: Logback configuration error detected: 
    ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE-MESSAGES-BODIES] - Failed to create parent directories for [C:\MY_PATH\file.log]
    ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE-MESSAGES-BODIES] - openFile(C:\MY_PATH\file.log,true) call failed. java.io.FileNotFoundException: C:\MY_PATH\file.log (The device is not ready)
    ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE-LOG] - Failed to create parent directories for [C:\MY_PATH\file.log]

      

Using Spring Boot (v1.5.3)

+3


source to share


1 answer


As mentioned in the documentation , you can configure a system property org.springframework.boot.logging.LoggingSystem

with a value none

to disable the Spring Boot registration system. You can then use logback.xml

as usual to configure logging, or omit it to use the default configuration for backup.



+1


source







All Articles