-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mark and Mikolaj,
On 2/12/2009 6:19 AM, Mark Thomas wrote:
> Mikolaj Rydzewski wrote:
>> Mark Thomas wrote:
>>> As well as JDBC drivers, logging frameworks are frequent culprits for
>>> causing this.
>>>
>> What about commons-logging and log4j?
>>
> [snip]
>
> If commons-logging and log4j and deployed as part of your webapp you should
> be OK.
I have written a contextListener that attempts to clean-up after log4j
during webapp shutdown. It also reads my log4j configuration on startup,
which you can probably ignore. Maybe this would help you:
package org.childhealthcare.diagnosis.servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger;
import org.apache.log4j.LogManager;
/**
* A listener to initialize log4j.
*
* @author Chris Schultz
* @version $Revision: 1.1 $ $Date: 2008-05-27 21:11:53 $
*/
public class Log4jListener
implements ServletContextListener
{
private Logger logger;
public void contextInitialized(ServletContextEvent e)
{
// Trigger loading of the log4j.properties file from the classpath.
new PropertyConfigurator();
logger = Logger.getLogger(this.getClass());
logger.info("Log4j initialized");
}
public void contextDestroyed(ServletContextEvent e)
{
if(LogManager.class.getClassLoader()
.equals(this.getClass().getClassLoader()))
{
logger.info("Log4j was loaded by application classloader;
shutting down.");
LogManager.shutdown();
}
else
{
logger.info("Log4j was loaded by some other ClassLoader; not
shutting down.");
}
}
}
Whenever I stop Tomcat, though, I get this message (after the "log4j was
loaded by webapp classloader" message) in catalina.out:
Feb 12, 2009 5:49:19 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
log4j:ERROR LogMananger.repositorySelector was null likely due to error
in class reloading, using NOPLoggerRepository.
I'm a little unclear as to whether that log4j error message is coming
from Tomcat trying to shut down log4j or what. log4j.jar is only
available in my webapp's WEB-INF/lib directory.
<shrug>
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkmUqDIACgkQ9CaO5/Lv0PBHxgCfYoe3cXiRJD2ajzZn0fEJsq2G
uH4An3jmJa8YOvWhiDSjFhkzmRlThzYE
=qKFd
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]