Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1620

log messages in contextDestroyed does not work anymore

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.2.3
    • None
    • None
    • Apache Tomcat 9.0.41

      OpenJDK 16

      slf4j 1.7.31

      logback 1.2.3

    Description

      I am using slf4j 1.7.31 and logback 1.2.3 to log messages in a application for Apache Tomcat. I added the annotation @WebListener to one class, which handle various tasks on start/shutdown of the application. Here are the important parts of this class:

      @WebListener
      public class AutoLoad implements ServletContextListener {
      
      	private static final Logger log = LoggerFactory.getLogger(AutoLoad.class);
      
      	public void contextInitialized(ServletContextEvent event) {
      		log.info("Starting {}", APP_NAME);
      	}
      
      	public void contextDestroyed(ServletContextEvent event) {
      		log.info("Shutting down {}", APP_NAME);
      		if (LoggerFactory.getILoggerFactory() instanceof LoggerContext) {
      			((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
      		}
      	} 
      }

      I always see the starting-message. But since some versions of logback I no longer see the shutdown-message. It still works, if I replace logback with slf4j-simple.

      This is possibly related: I had to add this line
      > LoggerFactory.getILoggerFactory()).stop();
      because I suddently got warning on shutdown.

       

      Edit: According to our Jira, I added an issue for this on 28/Mar/17 11:57 AM, but didn't had time yet to report this to you.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            JP95 John Pace
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: