[英]how to keep springboot default log when using logback-spring.xml
the springboot default log is something like following: springboot 默认日志如下所示:
2020-04-06 19:34:11.323 INFO 19308 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-04-06 19:34:11.323 INFO 19308 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-04-06 19:34:11.424 INFO 19308 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-04-06 19:34:11.424 INFO 19308 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initializ
And I wrote a logback-spring.xml for setting some logger and appender for my application.我写了一个 logback-spring.xml 来为我的应用程序设置一些记录器和附加程序。 However, when the logback-spring.xml exists in "resources" directory, the springboot default log will disappear.
但是,当“resources”目录下存在logback-spring.xml时,springboot默认日志会消失。 And there is only a
<configuration>
without any subelement in logback-spring.xml. logback-spring.xml 中只有一个
<configuration>
没有任何子元素。
I have read the part of springboot document which is about logging and got the file .我已经阅读了 springboot 文档中有关记录并获取文件的部分。 But I don't know how to use it...I tried to copy the element
<property name="CONSOLE_LOG_PATTERN...
into my logback-spring.xml and using it as the formatter of my appender, then attaching the appender to <root>
. But it can't work.但我不知道如何使用它...我尝试将元素
<property name="CONSOLE_LOG_PATTERN...
<root>
. 但它不能工作。
Thanks.谢谢。
You need to include the base configuration in your logback-spring.xm file.您需要在 logback-spring.xm 文件中包含基本配置。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="your.application.package" level="DEBUG"/>
</configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.