如何禁用Spring Boot日志记录配置?

时间:2015-04-17 21:23:44

标签: java spring spring-boot

我正在使用Spring Boot并希望完全禁用自动日志记录配置,而是直接使用SLF4J和logback。

我尝试过以下方法:

@EnableAutoConfiguration(exclude={LoggingApplicationListener.class})

哪个不起作用。有没有办法完全禁用spring boot logging配置?

3 个答案:

答案 0 :(得分:2)

我相信Spring使用的属性会覆盖默认配置集和您正在使用的注释。

我曾遇到过同样的问题,我通过指定以下内容解决了这个问题:

-Dlogging.config=log4j-live.xml -Dlog4j.debug

请告诉我这是否适合您。

答案 1 :(得分:1)

查看Dave Syer的回答。我认为擦除Spring Boot默认日志配置是最好的办法。

Spring Boot programmatic logging configuration

答案 2 :(得分:1)

如果您不想配置JAVA_OPTS,可以按Spring Boot: LoggingApplicationListener interfering with Application Server logging

中所述覆盖SpringBootServletInitializer的行为