Bug 49792

Summary: The clearReferencesLogFactoryRelease removes all loggers in the JVM (instead of only removing all loggers of the Web application that is being undeployed)
Product: Tomcat 7 Reporter: S. Ali Tokmen <postmaster>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: regression CC: postmaster
Priority: P2    
Version: 7.0.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on: 49791    
Bug Blocks:    

Description S. Ali Tokmen 2010-08-20 15:05:31 UTC
In Tomcat 6.0.29, there's a new parameter in WebappClassLoader: clearReferencesLogFactoryRelease

It is by default true, and executes the following code when undeploying a web application:

        // Clear the classloader reference in common-logging
        if (clearReferencesLogFactoryRelease) {
            org.apache.juli.logging.LogFactory.release(this);
        }

The called method on JULI does the following:

        java.util.logging.LogManager.getLogManager().reset();

Which basically removes all handlers of all loggers of the Java util logger.

This cause a severe regression: all other applications in the same JVM as Tomcat do not log anything anymore (since their handlers have disappeared).

Is this an expected behaviour? How do we tell Catalina to only remove the handlers for the loggers by the Web application that is being undeployed?

For now, in the Tomcat integration in our application server, we have worked around the problem by setting clearReferencesLogFactoryRelease to false. This is of course a very bad workaround.

Cheers

S. Ali Tokmen
http://ali.tokmen.com/
Comment 1 S. Ali Tokmen 2010-08-20 15:08:08 UTC
Sorry, I meant Tomcat 7.0.0 and Tomcat 7.0.2 instead of 6.0.29.
Comment 2 S. Ali Tokmen 2010-08-21 07:55:10 UTC
The fix would I guess look like that:

    To clean up all of the current Web application's loggers:

    get all loggers' names
    for each logger
        get all handlers
        for each handler
            if the handler's class can be loaded using the WebAppClassLoader
               AND cannot be loaded using the WebAppClassLoader's parent
            then
              remove this handler
            else don't touch
              // that logger belongs to some other application or to Tomcat itself
Comment 3 Mark Thomas 2010-08-22 09:34:08 UTC

*** This bug has been marked as a duplicate of bug 48716 ***