spring boot 2攻略从构建小系统书
168元
(需用券)
去购买 >
1.引入jar包
org.slf4j
slf4j-api
1.7.25
2.编写application.properties/yml
#.properties
logging.config= classpath:logback-spring.xml
logging.file= #存放路径
#.yml
logging:
config: classpath:logback-spring.xml
file: #存放路径
3.编写logback-spring.xml
我们在src/main/resources中创建一个logback-spring.xml,注意:-spring在application之后可以扫描到,如果只写logback.xml那么该xml就会优先于application.yml进行扫描,因此无效
logback-spring
WARN
${CONSOLE_LOG_PATTERN}
UTF-8
${logging.path}/web_debug.log
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
UTF-8
${logging.path}/web-debug-%d{yyyy-MM-dd}.%i.log
100MB
15
debug
ACCEPT
DENY
${logging.path}/web_info.log
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
UTF-8
${logging.path}/web-info-%d{yyyy-MM-dd}.%i.log
100MB
15
info
ACCEPT
DENY
${logging.path}/web_warn.log
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
UTF-8
${logging.path}/web-warn-%d{yyyy-MM-dd}.%i.log
100MB
15
warn
ACCEPT
DENY
${logging.path}/web_error.log
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
UTF-8
${logging.path}/web-error-%d{yyyy-MM-dd}.%i.log
100MB
15
ERROR
ACCEPT
DENY
4.效果
java 11官方入门(第8版)教材
79.84元
包邮
(需用券)
去购买 >