Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
package ch.qos.logback.classic.selector.servlet;
import static ch.qos.logback.classic.ClassicConstants.JNDI_CONTEXT_NAME;
public class ContextDetachingSCL implements ServletContextListener {
  public void contextDestroyed(ServletContextEvent servletContextEvent) {
    String loggerContextName = null;
    try {
      Context ctx = JNDIUtil.getInitialContext();
      loggerContextName = (String) JNDIUtil.lookup(ctx);
    } catch (NamingException ne) {
    if (loggerContextName != null) {
      ..println("About to detach context named " + loggerContextName);
      ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector();
      LoggerContext context = selector.detachLoggerContext(loggerContextName);
      if (context != null) {
        Logger logger = context.getLogger(.);
        logger.warn("Stopping logger context " + loggerContextName);
        // when the web-app is destroyed, its logger context should be stopped
      } else {
        ..println("No context named " + loggerContextName + " was found.");
  public void contextInitialized(ServletContextEvent arg0) {
    // do nothing
New to GrepCode? Check out our FAQ X