Spring Boot: LoggingApplicationListener interfering with Application Server logging

前端 未结 2 767
北海茫月
北海茫月 2021-01-04 08:52

Spring Boot automatically initializes the underlying logging system using the LoggingApplicationListener. This is a nice thing if the application I\'m developin

相关标签:
2条回答
  • 2021-01-04 09:35

    thank you for you post it is very helpful. I had the same problem with Websphere Aplication Server: After spring boot context initialized I had no more logs. This solution is equivalent but less dirty by overriding the run method of SpringBootServletInitializer:

    @Override
        protected WebApplicationContext run(SpringApplication application) {
            Collection<ApplicationListener<?>> listeners =
                    new ArrayList<>();
            for (ApplicationListener<?> listener: application.getListeners()) {
                if (!(listener instanceof LoggingApplicationListener)) {
                    listeners.add(listener);
                }
            }
            application.setListeners(listeners);
            return super.run(application);
        }
    
    0 讨论(0)
  • 2021-01-04 09:35

    Since Spring Boot 1.4 the LoggingSystem autoconfiguration can be disabled.

    Take a look at the Custom Log Configuration section of the Spring documentation:

    You can force Spring Boot to use a particular logging system by using the org.springframework.boot.logging.LoggingSystem system property. The value should be the fully qualified class name of a LoggingSystem implementation. You can also disable Spring Boot’s logging configuration entirely by using a value of none.

    For Tomcat, for example, set the environment variable JAVA_OPTS:

    JAVA_OPTS="-Dorg.springframework.boot.logging.LoggingSystem=none"
    
    0 讨论(0)
提交回复
热议问题