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

Solution 1:

Use logging.file.name instead of logging.file

In higher versions of spring-boot-parent(from version 2.2.0), property logging.file is deprecated.

Solution 2:

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.)

Solution 3:

In my case, I used below, in the application property file.

logging.file

Instead, I need to use the below one:

logging.file.name

Since then, I could be able to get the logs into the directed path file.

Solution 4:

I had the same problem. It's more than likely due to file permissions on the file system. I had the application folder owned by root, but ./logs owned by the process owner. As such, the following didn't work:

logging.file=my.log

but this did

logging.file=/opt/myapp/logs/my.log