Spring Boot 1.1.4 doesn't read custom logback.xml from war file
This is only a problem with WAR packaging. This used to work in 1.1.3, but after upgrading to 1.1.4 it always reads from the default logback config.
It works for me. I added logback.xml in src/main/resources to the completed app from the jar to war getting started guide. It ends up in WEB-INF/classes when built with either Maven or Gradle and is then found as expected when deployed to Tomcat 7.0.54.
Perhaps you can provide some more info (Maven or Gradle, which servlet container, etc) or a sample project that illustrates the problem?
Sure, how do I do that?
Created a spring-boot-issues PR https://github.com/spring-projects/spring-boot-issues/pull/8
Perfect, thanks. I'll take a look.
I still can't reproduce the problem. Deploying the repro app to Tomcat 7.0.54 and accessing / produces the following logging to the console:
2014-07-17 16:04:59,740 INFO 73420 [http-bio-8080-exec-4] [] o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization started
2014-07-17 16:04:59,750 INFO 73420 [http-bio-8080-exec-4] [] o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization completed in 10 ms
2014-07-17 16:04:59,763 INFO 73420 [http-bio-8080-exec-4] [dac710af-8dad-48df-9765-88d0f0a411e8] hello.SampleController - Hello World! dac710af-8dad-48df-9765-88d0f0a411e8
Note that the reference id that's placed in the MDC is included in the third line of output.
Let me look at the WAR packaging issue a little further. However, if you try to run mvn spring-boot:run on 1.1.3 and 1.1.4, you should notice the difference.
Thanks. I've found the problem.
In application.properties you've set logging.config to classpath:/logback.xml which is the documented default location. Unfortunately, the docs are wrong and the default location is actually classpath:logback.xml (note that there's no slash).
As far as I can tell, the behaviour difference between running as a war deployed to Tomcat and running as a standalone application is due to the different class loader that's involved and their handling of a path that begins with /. In the latter case the / prevents the config file from being found.
You can fix your app either by removing the configuration of logging.config altogether (it's redundant as you're setting it to the default location), or by changing the value to classpath:logback.xml.