Examples of ContextSelector


Examples of ch.qos.logback.classic.selector.ContextSelector

          if (method.getName().equals("getContextSelector")) {
            //System.out.println("Logger context selector method found");
            //get the context selector
            StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
            Method m1 = binder.getClass().getMethod("getContextSelector", (Class[]) null);
            ContextSelector selector = (ContextSelector) m1.invoke(binder, (Object[]) null);
            //get the context for the given context name or default if null
            LoggerContext ctx = null;
            if (contextName != null && contextName.length() > 0) {
              ctx = selector.getLoggerContext(contextName);
            }
            // and if we get here, fall back to the default context
            if (ctx == null) {
              ctx = selector.getLoggerContext();
            }
            //debug
            //StatusPrinter.print(ctx);
            //get the logger from the context or default context
            logger = ((ctx != null) ? ctx.getLogger(clazz) : selector.getDefaultLoggerContext().getLogger(clazz));
            break;
          }
        }
      } catch (Exception e) {
        //no logback, use whatever logger is in-place
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

        if (method.getName().equals("getContextSelector")) {
          //System.out.println("Logger context selector method found");
          //get the context selector
          StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
          Method m1 = binder.getClass().getMethod("getContextSelector", (Class[]) null);
          ContextSelector selector = (ContextSelector) m1.invoke(binder, (Object[]) null);
          //get the context for the given context name or default if null
          LoggerContext ctx = null;
          if (contextName != null && contextName.length() > 0) {
            ctx = selector.getLoggerContext(contextName);
          }
          // and if we get here, fall back to the default context
          if (ctx == null) {
            ctx = selector.getLoggerContext();
          }
          //debug
          //StatusPrinter.print(ctx);
          //get the logger from the context or default context
          logger = ((ctx != null) ? ctx.getLogger(name) : selector.getDefaultLoggerContext().getLogger(name));
          break;
        }
      }
    } catch (Exception e) {
      //no logback, use whatever logger is in-place
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

    }
    return logger;
  }

  public static ContextSelector getContextSelector() {
    ContextSelector selector = null;
    StaticLoggerBinder binder = StaticLoggerBinder.getSingleton();
    try {
      Method m1 = binder.getClass().getMethod("getContextSelector", (Class[]) null);
      selector = (ContextSelector) m1.invoke(binder, (Object[]) null);
    } catch (Exception e) {
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

  public void doFilter(ServletRequest request, ServletResponse response,
      FilterChain chain) throws IOException, ServletException {

    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    ContextSelector selector = StaticLoggerBinder.getSingleton().getContextSelector();
    ContextJNDISelector sel = null;

    if (selector instanceof ContextJNDISelector) {
      sel = (ContextJNDISelector)selector;
      sel.setLocalContext(lc);
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

    }
   
    if (loggerContextName != null) {
      System.out.println("About to detach context named " + loggerContextName);
     
      ContextSelector selector = StaticLoggerBinder.getSingleton().getContextSelector();
      LoggerContext context = selector.detachLoggerContext(loggerContextName);
      if (context != null) {
        Logger logger = context.getLogger(LoggerContext.ROOT_NAME);
        logger.warn("Stopping logger context " + loggerContextName);
        // when the web-app is destroyed, its logger context should be stopped
        context.stop();
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

  /**
   * Return the name of the current context name as found in the logging event.
   */
  public String getDiscriminatingValue(ILoggingEvent event) {
    ContextSelector selector = ContextSelectorStaticBinder.getSingleton()
        .getContextSelector();

    if (selector == null) {
      return defaultValue;
    }

    LoggerContext lc = selector.getLoggerContext();
    if (lc == null) {
      return defaultValue;
    }

    return lc.getName();
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

    }
   
    if (loggerContextName != null) {
      System.out.println("About to detach context named " + loggerContextName);
     
      ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector();
      if(selector == null) {
        System.out.println("Selector is null, cannot detach context. Skipping.");
        return;
      }
      LoggerContext context = selector.detachLoggerContext(loggerContextName);
      if (context != null) {
        Logger logger = context.getLogger(Logger.ROOT_LOGGER_NAME);
        logger.warn("Stopping logger context " + loggerContextName);
        // when the web-app is destroyed, its logger context should be stopped
        context.stop();
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

    }
   
    if (loggerContextName != null) {
      System.out.println("About to detach context named " + loggerContextName);
     
      ContextSelector selector = StaticLoggerBinder.getSingleton().getContextSelector();
      LoggerContext context = selector.detachLoggerContext(loggerContextName);
      if (context != null) {
        Logger logger = context.getLogger(Logger.ROOT_LOGGER_NAME);
        logger.warn("Stopping logger context " + loggerContextName);
        // when the web-app is destroyed, its logger context should be stopped
        context.stop();
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

  /**
   * Return the name of the current context name as found in the logging event.
   */
  public String getDiscriminatingValue(ILoggingEvent event) {
    ContextSelector selector = ContextSelectorStaticBinder.getSingleton()
        .getContextSelector();

    if (selector == null) {
      return defaultValue;
    }

    LoggerContext lc = selector.getLoggerContext();
    if (lc == null) {
      return defaultValue;
    }

    return lc.getName();
View Full Code Here

Examples of ch.qos.logback.classic.selector.ContextSelector

  public void doFilter(ServletRequest request, ServletResponse response,
      FilterChain chain) throws IOException, ServletException {

    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    ContextSelector selector = LoggerFactory.getContextSelector();
    ContextJNDISelector sel = null;

    if (selector instanceof ContextJNDISelector) {
      sel = (ContextJNDISelector)selector;
      sel.setLocalContext(lc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.