Console log is by default activated in spring boot. I like to log to file, e.g. /var/log/mylog.log.

How to enable file logging in spring boot?

1 Answers

0
Sma Ma On

According to Spring Boot documentation you have to enable file logging by setting a property in your application configuration (application.properties / application.yaml / etc.).

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-logging-file-output

By default, Spring Boot logs only to the console and does not write log files. If you want to write log files in addition to the console output, you need to set a logging.file or logging.path property (for example, in your application.properties).

For example in application.properties:

logging.file=myFile

Writes to the specified log file. Names can be an exact location or relative to the current directory.

logging.path=/var/log

Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory.