-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike,

On 10/26/2011 2:40 AM, Mike wrote:
> Understood. Thanks! I changed the logfile location to be the log
> folder of the tomcat server and the redeploy is working (amongst 10
> redeploys only 1 failed). I am using log4j so I don't control the
> process of shutting down the logging system (at least I wouldn't
> know how to).

Use a ServletContextListener like this to both configure and shutdown
log4j:

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.");
        }
    }
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6phXsACgkQ9CaO5/Lv0PBVRQCfcN9ez7DO/f74fJNTySL+gfBF
6d4AoJBTaA/Uai7kwz4hgP6QKnD2/XVI
=+G4j
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to