注意:同时配置了logging.file和logging.path只有一个生效。
例如 application.properties文件中的日志配置如下
logging.file=mylog.txt
logging.path=/var/myapp/
实际只有logging.file=mylog.txt生效,程序并保护会在/var/myapp目录下生成mylog.txt。
如果我们需要配置日志路径,可以在logging.file中配置。例如logging.file=/my-folder/my-file.txt
参看官方文档:
Table 26.1. Logging properties
logging.file | ogging.path | Example Description | 说明 |
---|---|---|---|
(none) | (none) | Console only logging | |
Specific file | (none) | my.log | Writes to the specified log file. Names can be an exact location or relative to the current directory. |
(none) | Specific file | /var/log | Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory. |