简体   繁体   English

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

[英]How can I disable Spring Boot logging configuration?

I am using Spring Boot and want to completely disable the automatic logging configuration and use SLF4J and logback directly instead. 我正在使用Spring Boot并希望完全禁用自动日志记录配置并直接使用SLF4J和logback。

I've tried the following: 我尝试过以下方法:

@EnableAutoConfiguration(exclude={LoggingApplicationListener.class})

Which didn't work. 哪个没用。 Is there a way to completely disable the spring boot logging configuration? 有没有办法完全禁用Spring启动日志记录配置?

I believe that Spring uses a property that overrides the configuration set by default and the annotation you're using. 我相信Spring使用的属性会覆盖默认配置集和您正在使用的注释。

I once had the same problem and I solved it by specifying the following: 我曾经遇到过同样的问题,我通过指定以下内容解决了这个问题:

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

Let me know if that works for you. 如果这对您有用,请告诉我。

Check out Dave Syer's answer. 查看Dave Syer的回答。 I think it is the best thing you can do to erase Spring Boot default logging config. 我认为擦除Spring Boot默认日志配置是最好的办法。

Spring Boot programmatic logging configuration Spring Boot程序化日志记录配置

如果您不想配置JAVA_OPTS ,可以覆盖SpringBootServletInitializer行为,如Spring Boot:LoggingApplicationListener中所述, 干扰Application Server日志记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM