logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 44557] New: no close call to Appender after replacing the root logger
Date Fri, 07 Mar 2008 14:01:44 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=44557

           Summary: no close call to Appender after replacing the root
                    logger
           Product: Log4j
           Version: 1.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: mirkojahn@gmail.com


In my Scenario I need a custom Logger and RootLogger so I created one
accordingly, let's call it CustomLogger and RootCustomLogger. Now, when I try
to use my newly created logger in the following way:

Hierarchy h = new Hierarchy(new RootCustomLogger((Level)Level.DEBUG));
LogManager.setRepositorySelector(new DefaultRepositorySelector(h), null);
DOMConfigurator.configure(someURL);

I noticed that the default RootLogger is first loaded and configured in the
static  initialization block. However, when the new DefaultRepositorySelector
is set in the LogManager.setRepositorySelector method, no clean-up of the old
RootLogger, contained in the former DefaultRepositorySelector is done. 

This can cause a problem if any of the configured Appenders is still holding
resources like file handles (the RollingFileAppender is a good example for
that).

In my case, I just inserted the following statement in the
LogManager.setRepositorySelector method, before the new RepositorySelector is
assigned to the repositorySelector field in the last line of the method:

// if the root logger didn't change, no reason to do that, I guess.      
if(!selector.getLoggerRepository().getRootLogger().equals(LogManager.getRootLogger())){
   LogManager.getRootLogger().removeAllAppenders();
}

Not sure, if there are any further clean ups necessary, but for me it does the
trick.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message