public void contextDestroyed()

in log4j-jakarta-web/src/main/java/org/apache/logging/log4j/web/Log4jServletContextListener.java [97:124]


    public void contextDestroyed(final ServletContextEvent event) {
        if (this.servletContext == null || this.initializer == null) {
            LOGGER.warn("Servlet context destroyed before it was initialized.");
            return;
        }

        if (decrementAndGetCount() != 0) {
            LOGGER.debug(
                    "Skipping Log4j context shutdown, since {} is registered multiple times.",
                    getClass().getSimpleName());
            return;
        }
        LOGGER.info("{} triggered a Log4j context shutdown.", getClass().getSimpleName());
        try {
            this.initializer.clearLoggerContext(); // the application is finished
            // shutting down now
            final String stopTimeoutStr = servletContext.getInitParameter(KEY_STOP_TIMEOUT);
            final long stopTimeout =
                    Strings.isEmpty(stopTimeoutStr) ? DEFAULT_STOP_TIMEOUT : Long.parseLong(stopTimeoutStr);
            final String timeoutTimeUnitStr = servletContext.getInitParameter(KEY_STOP_TIMEOUT_TIMEUNIT);
            final TimeUnit timeoutTimeUnit = Strings.isEmpty(timeoutTimeUnitStr)
                    ? DEFAULT_STOP_TIMEOUT_TIMEUNIT
                    : TimeUnit.valueOf(toRootUpperCase(timeoutTimeUnitStr));
            this.initializer.stop(stopTimeout, timeoutTimeUnit);
        } catch (final IllegalStateException e) {
            throw new IllegalStateException("Failed to shutdown Log4j properly.", e);
        }
    }