看一下spring的官網方文檔
logging.file.name |
logging.file.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 directory | /var/log |
Writes spring.log to the specified directory. Names can be an exact location or relative to the current directory. |
logging.file.name 可以指定路徑和log文件的名字
logging.file.path 只可以只當log的路徑, 不能指定log的名字, 使用缺省值spring.log
二者只可以存在一個
#log levels
-
設置日志級別
logging: level: root: debug #指定根日志記錄級別, 即全局 com.chz.controller: trace #指定包日志記錄級別 debug: true #輸出更多裝配信息, 但是日志不會被設為debug level
#log groups
-
管理不同包的統一日志級別
logging:
level:
my: error
group:
my: [com.chz.controller, com.chz.entity]
#自定義日志文件
Logging System | Customization |
---|---|
Logback | logback-spring.xml , logback-spring.groovy , logback.xml , or logback.groovy |
Log4j2 | log4j2-spring.xml or log4j2.xml |
JDK (Java Util Logging) | logging.properties |