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

前端 未结 15 1494
一向
一向 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:52

    I found a solution. I am not very happy with it since it still does not answer my original question why the logging.file property is not respected.

    I created the logback-spring.xml from Georges' answer in the same directory where application.properties resides. According to the documentation Spring Boot will pick it up from there. Apparently, this does not happen in my case.

    I need to additionally add logging.config=classpath:logback-spring.xml in order it is picked up by Spring. The relevant parts of my application.properties are now

    logging.config=classpath:logback-spring.xml
    logging.file=logs/logfile.log
    

    (I created the logs directory manually.)

提交回复
热议问题