1

This is a follow-up from Spring @PreDestroy: No logging because Logback stops too soon.

In that question, user Dovmo gave a good suggestion on how to stop Logback from listening as a ServletContainerInitializer to self-destruct when the servlet is stopped. This works great.

I am now looking for a way to be able to destruct Logback as late as possible, preferable after every other bean has been destructed. In theory, I could add a @DependsOn(logback-bean) to every bean, but that would be very ugly. I also tried listening as a @WebListener and listen to the ServletContextEvent event, but these events seem to arrive before the first @PreDestroy of some random bean is called.

Is there a nicer way to execute code after all beans are destructed? That would solve the puzzle on forcing Logback to always log everything.

Harrold_dev
  • 183
  • 6

0 Answers0