-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@PreDestroy methods: messages logged with logback are lost #24431
Comments
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 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. |
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. |
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. |
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):
spring-projects/spring-boot#11360
The text was updated successfully, but these errors were encountered: