Logback打印日志而不遵循logback-spring.xml,直到打印横幅之后[重复]

yzckvree  于 4个月前  发布在  Spring
关注(0)|答案(1)|浏览(47)

此问题在此处已有答案

How to prevent logback from outputting its own status at the start of every log when using a layout(11个回答)
上个月关门了。
当我运行我的Sping Boot 应用程序时,Logback会一直打印日志,直到横幅打印出来之后才应用logback-spring.xml中的设置(横幅之前的所有内容都是不同格式的,我想避免打印):

2019-03-04 13:15:25.151  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : 
2019-03-04 13:15:25.157  INFO   --- [           main] o.s.t.c.support.AbstractContextLoader    : 
2019-03-04 13:15:25.158  INFO   --- [           main] t.c.s.AnnotationConfigContextLoaderUtils : 
2019-03-04 13:15:25.298  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : 
2019-03-04 13:15:25.401  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : 
2019-03-04 13:15:25.430  INFO   --- [           main] .b.t.c.SpringBootTestContextBootstrapper : 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.2.RELEASE)

2019-03-04 13:15:25.886 DEBUG 7484 --- [           main] o.s.boot.SpringApplication               : 
2019-03-04 13:15:25.903 DEBUG 7484 --- [           main] o.s.b.c.c.ConfigFileApplicationListener  : 
2019-03-04 13:15:25.904 DEBUG 7484 --- [           main] o.s.b.c.c.ConfigFileApplicationListener  : 
2019-03-04 13:15:25.904 DEBUG 7484 --- [           main] o.s.b.c.c.ConfigFileApplicationListener  : 
2019-03-04 13:15:25.905 DEBUG 7484 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : 
2019-03-04 13:15:25.922 DEBUG 7484 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : 
2019-03-04 13:15:25.937 DEBUG 7484 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : 
2019-03-04 13:15:26.004 DEBUG 7484 --- [           main] o.s.c.a.ClassPathBeanDefinitionScanner   :

字符串
我读过文件:
由于标准logback.xml配置文件加载过早,因此无法在其中使用扩展。您需要使用logback-spring.xml或定义logging.config属性。
我假设默认配置比Sping Boot 更早加载日志配置。如果是这样,有没有办法让logback禁用所有日志,直到Sping Boot 接管?
我也研究了this solution并实现了它,但它似乎对我不起作用。是因为我使用的是Sping Boot 3.2.0吗?

t98cgbkg

t98cgbkg1#

我会尝试在src/main/resources中创建logback.xml文件并将日志记录级别更改为ERROR。
或者,您可以尝试使用springProperty标记。
有时,我们需要在logging配置中访问application.properties文件中的值。在这种情况下,我们在Logback配置中使用springProperty元素。
springProperty元素类似于Logback的标准属性元素。但是,我们可以从环境中确定属性的来源,而不是直接指定值。

相关问题