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 :)
Appenders. Apache log4j provides Appender objects which are primarily responsible for printing logging messages to different destinations such as consoles, files, sockets, NT event logs, etc. Each Appender object has different properties associated with it, and these properties indicate the behavior of that object.
The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file.
You can set a logger's level with the class Configurator from Log4j Core. BUT be aware that the Configurator class is not part of the public API. If you wish to change the root logger level, do something like this : LoggerContext ctx = (LoggerContext) LogManager.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With