Clear appenders call on logger calls a helper which calls close on the appenders, even though appenders are shared objects and may still be active in other loggers, or re-used later. You can't assume that removal equates to a desire to close.
Please attach a testcase demonstrating the behaviour you are reporting.
(In reply to comment #1) > Please attach a testcase demonstrating the behaviour you are reporting. > You've got to be kidding. It's directly in your code. Here's the stack trace... at org.apache.log4j.helpers.AppenderAttachableImpl.removeAllAppenders(AppenderAttachableImpl.java:141) at org.apache.log4j.Category.removeAllAppenders(Category.java:891) Calling Category.removeAllAppenders() results in a call to AppenderAttachableImpl.removeAllAppenders(), probably because this is set as the default listener for the remove event internally. Looking at the code fro the removeAllAppenders method in AppenderAttachableImpl, we see... public void removeAllAppenders() { if(appenderList != null) { int len = appenderList.size(); for(int i = 0; i < len; i++) { Appender a = (Appender) appenderList.elementAt(i); a.close(); } appenderList.removeAllElements(); appenderList = null; } } Look at that a.close(). Why is this method calling close on an Appender simply because it has been removed from a logger? Appenders are shared objects. I wonder how the other loggers that Appender is attached to will feel about it being closed underneath them? What happens when I re-use this Appender? In my opinion this is incorrect behavior.
(In reply to comment #2) > You've got to be kidding. It's directly in your code. Here's the stack trace... I am not kidding, and it is not my code (you can see that in the Subversion history). By providing a testcase it can be demonstrated that the bug exists, and that the patch removed the bug. Otherwise we can only guess what caused the bug and if the handwaving code introduced fixed it in the way you expected. Hence, please provide a testcase. > In my opinion this is incorrect behavior. Most likely.
There is enough info to address the bug, so I'm dropping the NEEDINFO designation. The behavior described is undesirable but long established. I don't think that removing the "a.close()" would be acceptable since some app might depend on removeAllAppenders() closing the appenders. However, I could see only closing the appenders that are not otherwise attached, however detecting that might be complicated.