Spring Boot - no log file written (logging.file is not respected)

前端 未结 15 1485
一向
一向 2020-12-14 00:01

I use Spring Boot and want it to write log output to a file.

According to the docs, this is simply done by setting

logging.file=filename.log
<         


        
15条回答
  •  别那么骄傲
    2020-12-14 00:46

    In my case I pasted some typical config and somehow most probably messed my logging pattern (logging.pattern.file)

    Commenting it out solved my own issue (file was created, but nothing was written in it, even though there was console output and root logging level was set to DEBUG) - no errors were given otherwise.

    [edit] In other case (I always seem to bump into this problem), I was referencing a JAR file with classes stripped from a web application (WAR), which contained a logback.xml, not to mention AppInitializer - I suspect AppInitializer wouldn't be a problem, since it has a completely different package name and shouldn't be scanned by Spring auto config.. but logback.xml was being detected, I guess, in the classpath, and messed everything completely. I knew it was a hack to reference a WAR, but I was hoping for a quick fix - fixing that, breaking something else. Mani's answer is related.

提交回复
热议问题