views:

656

answers:

1

My servlet-based web-app sometimes fails to close Log4j log files when redeployed, leaking to file descriptor leakage and occassionally leading to servlet-contained dying from 'too many open files'.

I have a ContextListener, what should I put into its contextDestroyed() to tell log4j to shut down and release all resources?

Quick skim over javadocs revealed Hierachery class with shutdown() method. I have no idea on how to actually get the current Hierachery, and the javadoc states this class has no user-serviceable components inside :)

+2  A: 

Try this:

org.apache.log4j.LogManager.shutdown();

However, the problem you are experiencing is strange and shouldn't be happening. What JVM, container, log4j version are you using?

kgiannakakis
I'm using Sun's JVM6, Resin and log4j 1.2.14I guess it sometimes leaks classloaders and prevents them from recycling (finalizing), I've not figured it out yet.Thanks for hint!
alamar