Spring @PreDestroy: No logging because Logback stops too soon
问题 In my project, I am using Logback as logging facility. I have the following class @Component class Test { @PreDestroy public void destroy() { try { ... } catch (Exception e) { LoggerFactory.getLogger(getClass()).error(e.getLocalizedMessage(), e); } } } Now, I undeploy the servlet. When an exception occurs, Logback is not printing the message and stack trace. This is because Logback is cleaning up before the destroy() is called by Spring. When undeploying the servlet, this is the first (and