ch.qos.logback.classic.Logger.setLevel()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(275)

本文整理了Java中ch.qos.logback.classic.Logger.setLevel()方法的一些代码示例,展示了Logger.setLevel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.setLevel()方法的具体详情如下:
包路径:ch.qos.logback.classic.Logger
类名称:Logger
方法名:setLevel

Logger.setLevel介绍

暂无

代码示例

代码示例来源:origin: dropwizard/dropwizard

@Override
  public void run() {
    logger.setLevel(null);
  }
}, millis);

代码示例来源:origin: SonarSource/sonarqube

private static void applyHardUnlessTrace(LoggerContext rootContext, String logger, boolean traceGloballyEnabled) {
 if (!traceGloballyEnabled) {
  rootContext.getLogger(logger).setLevel(Level.OFF);
 }
}

代码示例来源:origin: SonarSource/sonarqube

private static void applyHardcodedLevel(LoggerContext rootContext, String loggerName, Level newLevel) {
 rootContext.getLogger(loggerName).setLevel(newLevel);
}

代码示例来源:origin: spotify/helios

private void configureLogger(final String name, final Level level) {
  final ch.qos.logback.classic.Logger logger =
    (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(name);
  logger.setLevel(level);
 }
}

代码示例来源:origin: MovingBlocks/Terasology

/**
 * To disable the logger from some classes that throw errors and some other spam stuff into our console.
 *
 */
private void disableLogger(Class<?> clazz) {
  LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
  Logger l = loggerContext.getLogger(clazz);
  ((ch.qos.logback.classic.Logger) l).setLevel(Level.OFF);
}

代码示例来源:origin: ch.qos.logback/logback-classic

public void setLoggerLevel(String loggerName, String levelStr) {
  if (loggerName == null) {
    return;
  }
  if (levelStr == null) {
    return;
  }
  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) {
      logger.setLevel(level);
    }
  }
}

代码示例来源:origin: SonarSource/sonarqube

private void applyLevelByProperty(Props props, Logger logger, List<String> properties) {
 logger.setLevel(resolveLevel(props, properties.stream().toArray(String[]::new)));
}

代码示例来源:origin: ch.qos.logback/logback-classic

public LoggerContext() {
  super();
  this.loggerCache = new ConcurrentHashMap<String, Logger>();
  this.loggerContextRemoteView = new LoggerContextVO(this);
  this.root = new Logger(Logger.ROOT_LOGGER_NAME, null, this);
  this.root.setLevel(Level.DEBUG);
  loggerCache.put(Logger.ROOT_LOGGER_NAME, root);
  initEvaluatorMap();
  size = 1;
  this.frameworkPackages = new ArrayList<String>();
}

代码示例来源:origin: SonarSource/sonarqube

public void changeRoot(LogLevelConfig logLevelConfig, Level newLevel) {
 ensureSupportedLevel(newLevel);
 LoggerContext rootContext = getRootContext();
 rootContext.getLogger(ROOT_LOGGER_NAME).setLevel(newLevel);
 logLevelConfig.getConfiguredByProperties().forEach((key, value) -> rootContext.getLogger(key).setLevel(newLevel));
}

代码示例来源:origin: alibaba/nacos

@Override
public void setLevel(Level level) {
  this.level = level;
  logger.setLevel(ch.qos.logback.classic.Level.valueOf(level.getName()));
}

代码示例来源:origin: spotify/helios

private void setupLogging() {
  final LoggingConfig config = parser.getLoggingConfig();
  if (config.getNoLogSetup()) {
   return;
  }
  final int verbose = config.getVerbosity();
  final Level level = get(asList(WARN, INFO, DEBUG, ALL), verbose, ALL);
  final Logger rootLogger = (Logger) LoggerFactory.getLogger(ROOT_LOGGER_NAME);
  rootLogger.setLevel(level);
 }
}

代码示例来源:origin: gocd/gocd

private LogFixture(Logger logger, Level level) {
  this.logger = logger;
  this.appender = new ListAppender(LogHelper.encoder("%level %msg%n"));
  this.appender.start();
  logger.addAppender(appender);
  logger.setLevel(level);
}

代码示例来源:origin: ch.qos.logback/logback-classic

public void begin(InterpretationContext ec, String name, Attributes attributes) {
  inError = false;
  LoggerContext loggerContext = (LoggerContext) this.context;
  root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
  String levelStr = ec.subst(attributes.getValue(ActionConst.LEVEL_ATTRIBUTE));
  if (!OptionHelper.isEmpty(levelStr)) {
    Level level = Level.toLevel(levelStr);
    addInfo("Setting level of ROOT logger to " + level);
    root.setLevel(level);
  }
  ec.pushObject(root);
}

代码示例来源:origin: gocd/gocd

protected void configureDefaultLogging() {
  ((LoggerContext) loggerFactory).reset();
  // reset will cause log level to be set to debug, so we set it to something more useful
  LogHelper.rootLogger().setLevel(Level.INFO);
  new BasicConfigurator().configure((LoggerContext) loggerFactory);
}

代码示例来源:origin: spring-projects/spring-security

private Appender<ILoggingEvent> mockAppenderFor(String name) {
  Appender<ILoggingEvent> appender = mock(Appender.class);
  Logger logger = (Logger) LoggerFactory.getLogger(name);
  logger.setLevel(Level.DEBUG);
  logger.addAppender(appender);
  return appender;
}

代码示例来源:origin: ch.qos.logback/logback-classic

public void begin(InterpretationContext ec, String name, Attributes attributes) {
  Object o = ec.peekObject();
  if (!(o instanceof Logger)) {
    inError = true;
    addError("For element <level>, could not find a logger at the top of execution stack.");
    return;
  }
  Logger l = (Logger) o;
  String loggerName = l.getName();
  String levelStr = ec.subst(attributes.getValue(ActionConst.VALUE_ATTR));
  // addInfo("Encapsulating logger name is [" + loggerName
  // + "], level value is  [" + levelStr + "].");
  if (ActionConst.INHERITED.equalsIgnoreCase(levelStr) || ActionConst.NULL.equalsIgnoreCase(levelStr)) {
    l.setLevel(null);
  } else {
    l.setLevel(Level.toLevel(levelStr, Level.DEBUG));
  }
  addInfo(loggerName + " level set to " + l.getLevel());
}

代码示例来源:origin: SonarSource/sonarqube

private static void setCustomRootAppender(LoggingConfiguration conf) {
 Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
 String level = StringUtils.defaultIfBlank(conf.getSubstitutionVariables().get(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL), LoggingConfiguration.LEVEL_ROOT_DEFAULT);
 if (logger.getAppender(CUSTOM_APPENDER_NAME) == null) {
  logger.detachAndStopAllAppenders();
  logger.addAppender(createAppender(conf.getLogOutput()));
 }
 logger.setLevel(Level.toLevel(level));
}

代码示例来源:origin: SonarSource/sonarqube

public LoggingRule setLevel(Level level) {
 Logger logbackLogger = (Logger) LoggerFactory.getLogger(loggerClass);
 ch.qos.logback.classic.Level l = ch.qos.logback.classic.Level.valueOf(level.name());
 logbackLogger.setLevel(l);
 return this;
}

代码示例来源:origin: apache/incubator-dubbo

rootLogger.setLevel(Level.toLevel(level));
rootLogger.setAdditive(false);

代码示例来源:origin: apache/incubator-dubbo

rootLogger.setLevel(Level.toLevel(level));
rootLogger.setAdditive(false);

相关文章