Is there a way to force a Log4j Logger to be released/garbage collected?
In general, does Log4j “hang on” to Logger references in some static collection?
I see the Logger.shutdown() method, which is deprecated and refers to LoggerManager.shutdown(), which doesn’t sound like it addresses a single Logger instance.
You could take a look at the log4j source code yourself.
Based on a quick trawl, I think the answers are:
Not with that level of granularity. The only thing I could find was a method (
Heirarchy.clear()) that releases all loggers … and destroy the logging hierarchy in the process.Yes. And the collection doesn’t use weak references …