Affected: Spring MVC: 5.2.2 (and older most likely) Logback Version: 1.2.3
When using SLF4J with logback to log in a @PreDestroy method of a @Service class, the messages are lost because apparently logback shuts itself down before the user's @PreDestroy methods complete. Its easy to not notice the missing logs for a while.
The current workaround is to disable the servlet lifecycle feature of logback. Ideally either Spring or Logback would figure out when to shut Logback down without users having to workaround this (btw, i don't know if the current workaround has any negative effects like preventing proper Logback shutdown).
This is basically the same issue as: https://stackoverflow.com/questions/47184045/spring-predestroy-no-logging-because-logback-stops-too-soon and similar to (but for Spring instead of Spring Boot and logback instead of Log4j2): https://github.com/spring-projects/spring-boot/issues/11360
Comment From: rstoyanchev
You could try a web-fragment to your WAR mode that fixes the order of spring_web relative to other fragments with a declaration like this:
<absolute-ordering>
<others/>
<name>spring_web</name>
<name>ch.qos.logback.classic.servlet.LogbackServletContainerInitializer</name>
</absolute-ordering>
If this can be confirmed to work, I can add something to our docs, but I don't think we are in a position to control the order of ServletContainerInializers are invoked.
This reminds me also of a recent change in Tomcat related to the order of SCI initialization. If you're using Tomcat it's worth trying one of the fixed versions to see if it makes a difference.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.