spring boot日誌配置常用的配置項有:
logging.path=/var/log/ #配置日誌文件存儲路徑
logging.file=/var/log/my-log.log #配置日誌文件名,如果不指定默認爲spring.log
logging.file.max-history=10 #保存的最大日誌文件數量
logging.file.max-size=5MB #單個日誌文件最大的存儲容量,當超過此值,會生成一個新的日誌文件logging.level.root=INFO #ROOT log的記錄級別
關於springboot日誌配置 logging.path和logging.file 注意事項
可能有些小夥伴會同時配置 logging.path 和 logging.file,但是又發現其中一個不生效。
官方文檔中有這麼一句:
If you want to write log files in addition to the console output you
need to set a logging.file or logging.path property
也就是說,它們不會同時生效,只配置其中一個就好了。
例如我配置的時候只指定path
logging.path = ./logs
那麼記錄日誌的時候默認的文件名是:spring.log。