Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.LoggerContext


        } catch (NumberFormatException nfe) {
          addError("Error while converting [" + scanAttrib + "] to long", nfe);
        }
      }
      rocf.start();
      LoggerContext lc = (LoggerContext) context;
      addInfo("Adding ReconfigureOnChangeFilter as a turbo filter");
      lc.addTurboFilter(rocf);
    }
  }
View Full Code Here


  public void begin(InterpretationContext ec, String name, Attributes attributes) {
    // Let us forget about previous errors (in this object)
    inError = false;
    logger = null;
   
    LoggerContext loggerContext = (LoggerContext) this.context;

    String loggerName = ec.subst(attributes.getValue(NAME_ATTRIBUTE));

    if (OptionHelper.isEmpty(loggerName)) {
      inError = true;
      String aroundLine = getLineColStr(ec);
      String errorMsg = "No 'name' attribute in element " + name + ", around " +aroundLine;
      addError(errorMsg);
      return;
    }

    logger = loggerContext.getLogger(loggerName);

    String levelStr =  ec.subst(attributes.getValue(LEVEL_ATTRIBUTE));
   
    if (!OptionHelper.isEmpty(levelStr)) {
      if (ActionConst.INHERITED.equalsIgnoreCase(levelStr)
View Full Code Here

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

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

    return lc.getName();
  }
View Full Code Here

        addError("Port " + portStr
            + " in ConsolePlugin config is not a correct number");
      }
    }

    LoggerContext lc = (LoggerContext)ec.getContext();
    SocketAppender appender = new SocketAppender();
    appender.setContext(lc);
    appender.setIncludeCallerData(true);
    appender.setRemoteHost("localhost");
    appender.setPort(port.intValue());
    appender.start();
    Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
    root.addAppender(appender);
   
    addInfo("Sending LoggingEvents to the plugin using port " + port);
  }
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 = contextMap.get(contextName);

      if (loggerContext == null) {
        // We have to create a new LoggerContext
        loggerContext = new LoggerContext();
        loggerContext.setName(contextName);
        contextMap.put(contextName, loggerContext);

        // Do we have a dedicated configuration file?
        String configFilePath = JNDIUtil.lookup(ctx,
            JNDI_CONFIGURATION_RESOURCE);
View Full Code Here

        addError("Port " + portStr
            + " in ConsolePlugin config is not a correct number");
      }
    }

    LoggerContext lc = (LoggerContext)ec.getContext();
    SocketAppender appender = new SocketAppender();
    appender.setContext(lc);
    appender.setIncludeCallerData(true);
    appender.setRemoteHost("localhost");
    appender.setPort(port.intValue());
    appender.start();
    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
    root.addAppender(appender);
   
    addInfo("Sending LoggingEvents to the plugin using port " + port);
  }
View Full Code Here

      throwable = extractThrowableAnRearrangeArguments(argArray);
    }

    if (throwable != null) {
      this.throwableProxy = new ThrowableProxy(throwable);
      LoggerContext lc = logger.getLoggerContext();
      if (lc.isPackagingDataEnabled()) {
        this.throwableProxy.calculatePackagingData();
      }
    }

    timeStamp = System.currentTimeMillis();
View Full Code Here

      }
    }
  }

  private void propagateExistingLoggerLevels() {
    LoggerContext loggerContext = (LoggerContext) context;
    List<Logger> loggerList = loggerContext.getLoggerList();
    for (Logger l : loggerList) {
      if (l.getLevel() != null) {
        propagate(l, l.getLevel());
      }
    }
View Full Code Here

    }
    loggerName = loggerName.trim();
    levelStr = levelStr.trim();

    addInfo("Trying to set level " + levelStr + " to logger " + loggerName);
    LoggerContext lc = (LoggerContext) context;

    Logger logger = lc.getLogger(loggerName);
    if ("null".equalsIgnoreCase(levelStr)) {
      logger.setLevel(null);
    } else {
      Level level = Level.toLevel(levelStr, null);
      if (level != null) {
View Full Code Here

      return EMPTY;
    }

    loggerName = loggerName.trim();

    LoggerContext lc = (LoggerContext) context;
    Logger logger = lc.exists(loggerName);
    if (logger != null && logger.getLevel() != null) {
      return logger.getLevel().toString();
    } else {
      return EMPTY;
    }
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.