From the Spring documentation: A web application can define any number of DispatcherServlets. Each servlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by ContextLoaderListener, if any, will be shared. But the question is: Can you shut down only one web application context and keep the other web application contexts alive? I think not...? And is it predictable in which order the web application contexts will be shut downed? I think not...? Apart from having multiple web application contexts you don't know in which order the Spring beans will be destroyed. You must shutdown the logger context to release the file handles and the way to do that would be a Spring bean which stops the logger context in the @PreDestroy method. Therefore you don't know which Spring bean can do logging inside it's @PreDestroy method and which Spring bean cannot (because the logging context Spring bean is already destroyed). A workaround would be to use @DependsOn(logger bean) on all components... In conclusion: It seems to be difficult to log something while an application context is shutting down. |