Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.LoggerContext


      return EMPTY;
    }

    loggerName = loggerName.trim();

    LoggerContext lc = (LoggerContext) context;
    Logger logger = lc.exists(loggerName);
    if (logger != null) {
      return logger.getEffectiveLevel().toString();
    } else {
      return EMPTY;
    }
View Full Code Here


      return EMPTY;
    }
  }

  public List<String> getLoggerList() {
    LoggerContext lc = (LoggerContext) context;
    List<String> strList = new ArrayList<String>();
    Iterator<Logger> it = lc.getLoggerList().iterator();
    while (it.hasNext()) {
      Logger log = it.next();
      strList.add(log.getName());
    }
    return strList;
View Full Code Here

    public void run() {
      if (mainConfigurationURL == null) {
        addInfo("Due to missing top level configuration file, skipping reconfiguration");
        return;
      }
      LoggerContext lc = (LoggerContext) context;
      addInfo(CoreConstants.RESET_MSG_PREFIX + "named [" + context.getName() + "]");
      if (mainConfigurationURL.toString().endsWith("xml")) {
        performXMLConfiguration(lc);
      } else if (mainConfigurationURL.toString().endsWith("groovy")) {
        if (EnvUtil.isGroovyAvailable()) {
          lc.reset();
          // avoid directly referring to GafferConfigurator so as to avoid
          // loading  groovy.lang.GroovyObject . See also http://jira.qos.ch/browse/LBCLASSIC-214
          GafferUtil.runGafferConfiguratorOn(lc, this, mainConfigurationURL);
        } else {
          addError("Groovy classes are not available on the class path. ABORTING INITIALIZATION.");
View Full Code Here

    if (args.length == 4) {
      username = args[2];
      password = args[3];
    }

    LoggerContext loggerContext = (LoggerContext) LoggerFactory
        .getILoggerFactory();
    new ContextInitializer(loggerContext).autoConfig();

    new JMSQueueSink(qcfBindingName, queueBindingName, username, password);
View Full Code Here

  public LoggerContext getLoggerContext() {
    String contextName = null;
    Context ctx = null;

    // First check if ThreadLocal has been set already
    LoggerContext lc = threadLocal.get();
    if (lc != null) {
      return lc;
    }

    try {
      // We first try to find the name of our
      // environment's LoggerContext
      ctx = JNDIUtil.getInitialContext();
      contextName = (String) JNDIUtil.lookup(ctx, JNDI_CONTEXT_NAME);
    } catch (NamingException ne) {
      // We can't log here
    }

    if (contextName == null) {
      // We return the default context
      return defaultContext;
    } else {
      // Let's see if we already know such a context
      LoggerContext loggerContext = synchronizedContextMap.get(contextName);

      if (loggerContext == null) {
        // We have to create a new LoggerContext
        loggerContext = new LoggerContext();
        loggerContext.setName(contextName);
        synchronizedContextMap.put(contextName, loggerContext);
        URL url = findConfigFileURL(ctx, loggerContext);
        if (url != null) {
          configureLoggerContextByURL(loggerContext, url);
        } else {
View Full Code Here

  }

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

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

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

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

  }

  public void initialize() {
    try {
      // let's configure a default context
      LoggerContext defaultLoggerContext = new LoggerContext();
      defaultLoggerContext.setName("default");
      ContextInitializer.autoConfig(defaultLoggerContext);

      // See if a special context selector is needed
      String contextSelectorStr = OptionHelper.getSystemProperty(
          ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, null);
View Full Code Here

  }

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

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

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

   
    if (loggerContextName != null) {
      System.out.println("About to detach context named " + loggerContextName);
     
      ContextSelector selector = StaticLoggerBinder.SINGLETON.getContextSelector();
      LoggerContext context = selector.detachLoggerContext(loggerContextName);
      if (context != null) {
        Logger logger = context.getLogger(LoggerContext.ROOT_NAME);
        logger.warn("Shutting down context " + loggerContextName);
        context.shutdownAndReset();
      } else {
        System.out.println("No context named " + loggerContextName + " was found.");
      }
    }
  }
View Full Code Here

TOP

Related Classes of ch.qos.logback.classic.LoggerContext

Copyright © 2018 www.massapicom. 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.