Spring Boot日誌配置中的file和path注意事項
阿新 • • 發佈:2018-11-24
注意:同時配置了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. |