-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mark,
On 9/17/12 1:36 PM, Mark Eggers wrote: > So really, for me, it boils down to this. > > 1. Place log4j.xml in WEB-INF/classes 2. Write a servlet context > listener a. contextInitialized - just write something to the log b. > contextDestroyed - shut down logging if the app started it Yup. Here's mine: ... import javax.servlet.ServletContextListener; import javax.servlet.ServletContextEvent; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.Logger; import org.apache.log4j.LogManager; ... 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())) { if(null != logger) logger.info("Log4j was loaded by application classloader; shutting down."); LogManager.shutdown(); } else { if(null != logger) logger.info("Log4j was loaded by some other ClassLoader; not shutting down."); } } } -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBXewMACgkQ9CaO5/Lv0PA0OwCeINt42NSM5okJtTKbNra46If/ AlUAoLfG43X8GgMV5fJeQsaV8G1sEB57 =Nuh2 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org