Using spring-boot 1.2.3.RELEASE.
The only way I can get spring-boot to log to a specific directory is by setting the "log.file" property like so:
logging.file=/var/log/app.log
But as far as I can tell, according to the docs, I should be doing:
logging.file=app.log
logging.path=/var/log
But it just doesn't seem to listen to the logging.path property, it will just write the file to the current directory.
Are the docs wrong or is there something really obvious I'm missing here?
Also, with this setting, it's still going to do log rolling properly, right?
You can enable debug logging by specifying --debug when starting the application from the command-line. Spring Boot provides also a nice starting point for logback to configure some defaults, coloring etc. the base. xml file which you can simply include in your logback.
Spring Boot uses Apache Commons logging for all internal logging. Spring Boot's default configurations provides a support for the use of Java Util Logging, Log4j2, and Logback. Using these, we can configure the console logging as well as file logging.
By default, Spring Boot will only log to the console and will 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.
Spring Boot's default logging framework is Logback. Your application code should interface only with the SLF4J facade so that it's easy to switch to an alternative framework if necessary. Log4j2 is newer and claims to improve on the performance of Logback.
From the documentation:
If you want to write log files in addition to the console output you need to set a logging.file or logging.path property
Spring boot considers either file
or path
property, not both.
This page has all combinations of file
and path
properties.
Variables path
and file
can be used simultaneously in the following ways (application.yml):
logging: path: /var/log/ file: ${logging.path}app.log
As a result, spring-boot will keep a log in the file /var/log/app.log
using spring 2.4.5
this is work
logging.file.path=./log/
logging.file.name=${logging.file.path}mylog.txt
or
logging.file.name=./log2/mylog.txt
in summary
logging.file.path=. # write logs to the current directory
logging.file.path=/home/logs # write logs to /home/logs
logging.file.path=/mnt/logdir # write logs to /mnt/logdir
for Spring Boot 1.x : set logging.path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With