SpringBoot: Log related

1. logging framework

UCL JUL JBoss-logging logback log4j  log4j2 SLF4J, springBoot default choices are logback slf4j

2.springBoot default log level is info, you can be configured in a .properties file modified

级别:trace < debug < info < warn < error < fatal < off

Review:. Logging.level com.example.demo = the trace, blackened portion to project main class where the package

3. Save the log information to a file

In still .properties configuration file is added to the code logging.file.name = log, it is automatically saved to a log file. log file is automatically created, you can define a path, logging.file.path.

4. The display format defined in the log .properties, divided into:

Console Display Format: logging.pattern.console =% d {yyyy-MM-DD} [% thread]% -5level% logger {50} -% msg% n

Save log file formats: logging.pattern.file =% d {yyyy-MM-DD} ** [% thread] **% -5level **% logger {50} **% msg% n

logging.level.com.example.demo = trace
logging.file.name = log

logging.pattern.console=%d{yyyy-MM-DD} [%thread] %-5level %logger{50} - %msg%n 
# %d 日期 %thread线程名 %-5level 显示日志级别
#logger{50}显示日志长度
ogging.pattern.file=%d{yyyy-MM-DD} ** [%thread] ** %-5level ** %logger{50}** %msg%n

Other: Charles springboot official documents

Published 126 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_36880027/article/details/104390415