1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@RestController public class HelloController { Logger logger = LoggerFactory.getLogger(getClass()); @GetMapping ( "/test" ) public void test(){ logger.trace( "Trace 日志..." ); logger.debug( "Debug 日志..." ); logger.info( "Info 日志..." ); logger.warn( "Warn 日志..." ); logger.error( "Error 日志..." ); } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
|
@RestController @Slf4j public class HelloController { @GetMapping ( "/test" ) public void test(){ log.trace( "Trace 日志..." ); log.debug( "Debug 日志..." ); log.info( "Info 日志..." ); log.warn( "Warn 日志..." ); log.error( "Error 日志..." ); } } |
1
|
logging.level.root=trace |
1
|
logging.level.com.example=trace |
1
|
logging.file.path=/Volumes/BOOTCAMP/log |
1
|
logging.file.name=/Volumes/BOOTCAMP/log/my.log |
1
2
3
4
|
# 日志文件大小 logging.file.max-size=10MB # 保留的日志时间 logging.file.max-history=10 |
1
2
3
4
|
# 修改在控制台输出的日志格式 logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger : %msg%n # 修改输出到文件的日志格式 logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger : %msg%n |
1
2
3
4
|
# 修改在控制台输出的日志格式 logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %clr(%5p) [%thread] %clr(%logger){cyan} : %msg%n # 修改输出到文件的日志格式 logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger : %msg%n |
1
2
3
4
|
# 修改在控制台输出的日志格式 logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %clr(%5p) [%thread] %clr(%logger{45}){cyan} : %msg%n # 修改输出到文件的日志格式 logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger : %msg%n |
SpringBoot - 日志的配置和使用详解(SLF4j、Logback)
原文:https://www.cnblogs.com/ygfsy/p/14041516.html