[英]What is default CONSOLE_LOG_PATTERN used for Spring Boot logging and where to find it?
The Spring Boot reference documentation 4.6. Spring 引导参考文档4.6。 Custom Log Configuration states about the default system properties representing a default logging pattern to use on the console (only supported with the default Logback setup).
自定义日志配置状态有关默认系统属性的状态,这些属性表示要在控制台上使用的默认日志记录模式(仅支持默认的 Logback 设置)。
logging.pattern.console
logging.pattern.console
CONSOLE_LOG_PATTERN
CONSOLE_LOG_PATTERN
I guess the default log line look is familiar for all the Spring Boot framework users:我想所有 Spring 引导框架用户都熟悉默认的日志行:
2020-08-04 12:00:00.000 INFO 24568 --- [ main] c.c.MyWonderfulSpringApplication : The following profiles are active: local
As long as I want to take look on how it looks and get inspired for defining my own one, where can I find this default value for a currently used version of Spring Boot?只要我想看看它的外观并获得灵感来定义我自己的,我在哪里可以找到当前使用的 Spring Boot 版本的默认值?
I have just found out this configuration is available at the DefaultLogbackConfiguration
file under Spring Boot project:我刚刚发现此配置可在 Spring 引导项目下的
DefaultLogbackConfiguration
文件中找到:
private static final String CONSOLE_LOG_PATTERN = "%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}}){faint} "
+ "%clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} "
+ "%clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} "
+ "%clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}";
To find the pattern for a certain Spring Boot version, either:要查找某个 Spring 引导版本的模式,请执行以下任一操作:
DefaultLogbackConfiguration
DefaultLogbackConfiguration
The source of my finding is https://www.logicbig.com/tutorials/spring-framework/spring-boot/logging-console-pattern.html .我发现的来源是https://www.logicbig.com/tutorials/spring-framework/spring-boot/logging-console-pattern.html 。
If you are using logback-spring.xml
, then adding the following to your xml would automatically pick up spring's default logback configuration for console appender.如果您使用的是
logback-spring.xml
,那么将以下内容添加到您的 xml 将自动为控制台附加程序选择 spring 的默认 logback 配置。
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> <include resource="org/springframework/boot/logging/logback/console-appender.xml" /> <root level="INFO"> <appender-ref ref="CONSOLE" /> </root>
Reference: https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/html/howto.html#howto-configure-logback-for-logging参考: https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/html/howto.html#howto-configure-logback-for-logging
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.