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: [email protected]
ReportedBy: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]