Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.Logger


    }

    /** Disables logging messages (logback version) */
    private static void disableLogBackLibraryLogging() {
      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = lc.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.OFF);
    }
View Full Code Here


        gelf.setThreshold(Level.WARN);
        gelf.setHost(host);
        gelf.setPort(port);
        gelf.setHostName(hostName);

        final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);

        if (cleanRootLogger) {
            root.detachAndStopAllAppenders();
        }

        root.addAppender(gelf.build(root.getLoggerContext(), name, null));
    }
View Full Code Here

    try {
      String loggerName = path.segment(0);
      JSONObject toPut = OrionServlet.readJSONRequest(request);

      Logger logger = logService.getLogger(loggerName);
      if (logger == null) {
        final String msg = NLS
            .bind("Logger not found: {0}", loggerName);
        final ServerStatus error = new ServerStatus(IStatus.ERROR,
            HttpServletResponse.SC_NOT_FOUND, msg, null);
        return statusHandler.handleRequest(request, response, error);
      }

      String putlevel = toPut.getString(LogConstants.KEY_LOGGER_LEVEL);
      Level level = Level.toLevel(putlevel, logger.getLevel());
      logger.setLevel(level);

      LoggerResource loggerResource = new LoggerResource();
      loggerResource.setBaseLocation(baseLocation);
      loggerResource.setName(logger.getName());
      loggerResource.setLevel(logger.getLevel());
      loggerResource.setEffectiveLevel(logger.getEffectiveLevel());

      JSONObject result = loggerResource.toJSON();
      OrionServlet.writeJSONResponse(request, response, result);
      response.setHeader(ProtocolConstants.HEADER_LOCATION,
          result.getString(ProtocolConstants.KEY_LOCATION));
View Full Code Here

  }

  @Override
  protected IStatus performJob() {
    try {
      Logger logger = logService.getLogger(loggerName);

      if (logger == null) {
        String msg = NLS.bind("Logger not found: {0}", loggerName);
        return new ServerStatus(IStatus.ERROR,
            HttpServletResponse.SC_NOT_FOUND, msg, null);
      }

      LoggerResource loggerResource = new LoggerResource();

      loggerResource.setBaseLocation(baseLocation);
      loggerResource.setName(logger.getName());
      loggerResource.setLevel(logger.getLevel());
      loggerResource.setEffectiveLevel(logger.getEffectiveLevel());

      return new ServerStatus(Status.OK_STATUS,
          HttpServletResponse.SC_OK, loggerResource.toJSON());
    } catch (Exception e) {
      String msg = NLS
View Full Code Here

    private final CyclicBufferAppender<ILoggingEvent> logbuf;
    private final StringBuilder buf = new StringBuilder(64);
    private int nevents;

    public LogIterator() {
      final Logger root =
        (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
      logbuf = (CyclicBufferAppender<ILoggingEvent>) root.getAppender("CYCLIC");
    }
View Full Code Here

      LOG.warn("LoggerFactory is not a logback LoggerContext. No log appender is added. " +
                 "Logback might not be in the classpath");
    }

    LoggerContext loggerContext = (LoggerContext) loggerFactory;
    Logger rootLogger = loggerContext.getLogger(rootLoggerName);

    if (initMap.putIfAbsent(rootLoggerName, logAppender.getName()) != null) {
      // Already initialized.
      LOG.trace("Log appender {} is already initialized.", logAppender.getName());
      return;
    }

    LOG.info("Initializing log appender {}", logAppender.getName());


    // Display any errors during initialization of log appender to console
    StatusManager statusManager = loggerContext.getStatusManager();
    OnConsoleStatusListener onConsoleListener = new OnConsoleStatusListener();
    statusManager.add(onConsoleListener);

    logAppender.setContext(loggerContext);
    logAppender.start();

    rootLogger.addAppender(logAppender);
  }
View Full Code Here

    pl.setPattern("%-4relative [%thread] %-5level %class - %msg%n");
    pl.start();

    ca.setLayout(pl);
    ca.start();
    Logger rootLogger = lc.getLogger(LoggerContext.ROOT_NAME);
    rootLogger.addAppender(ca);
  }
View Full Code Here

     * Add an appender to Logback logging framework that will track the types of log messages made.
     */
    @PostConstruct
    public final void addMetricsAppenderToLogback() {
        final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
        final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);

        final InstrumentedAppender metrics = new InstrumentedAppender(this.metricRegistry);
        metrics.setContext(root.getLoggerContext());
        metrics.start();
        root.addAppender(metrics);
    }
View Full Code Here

    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) {
        logger.setLevel(level);
      }
    }
  }
View Full Code Here

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

TOP

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

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.