当前位置: 首页>>代码示例>>Java>>正文


Java LoggerConfig.getLevel方法代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.config.LoggerConfig.getLevel方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerConfig.getLevel方法的具体用法?Java LoggerConfig.getLevel怎么用?Java LoggerConfig.getLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.logging.log4j.core.config.LoggerConfig的用法示例。


在下文中一共展示了LoggerConfig.getLevel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: watch

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public void watch(Class<?> loggerClass, Level level) {
    this.loggerClass = loggerClass;
    Appender appender = new AbstractAppender(APPENDER_NAME, null, PatternLayout.createDefaultLayout()) {
        @Override
        public void append(LogEvent event) {
            logEvents.add(event);
        }
    };
    appender.start();
    final LoggerContext ctx = getLoggerContext();
    LoggerConfig loggerConfig = ctx.getConfiguration().getLoggerConfig(loggerClass.getName());
    oldLevel = loggerConfig.getLevel();
    loggerConfig.setLevel(level);
    loggerConfig.addAppender(appender, level, null);
    ctx.updateLoggers();
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:17,代码来源:LogTestRule.java

示例2: testReadException

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
/**
 * Tests that {@link oc.io.base.DecoupledInputStream#read()} terminates
 * normally when IOException is thrown in wrapped InputStream
 * 
 * @throws IOException
 */
@Test
public void testReadException() throws IOException {
	final byte b[] = new byte[1];

	// Temporary disable logging for avoiding annoying Exception trace
	final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	final Configuration config = ctx.getConfiguration();
	final LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
	final Level currentLevel = loggerConfig.getLevel();
	loggerConfig.setLevel(Level.FATAL);
	ctx.updateLoggers();

	final TestInputStream testInputStream = new TestInputStream(new IOException(
			"This exception is thrown due to a test scenario. This is expected behaviour"));
	final DecoupledInputStream decInputStream = new DecoupledInputStream(testInputStream);
	assertEquals(-1, decInputStream.read(b));
	decInputStream.close();

	loggerConfig.setLevel(currentLevel);
	ctx.updateLoggers();
}
 
开发者ID:oschuen,项目名称:ballin-happiness,代码行数:28,代码来源:DecoupledInputStreamTestCase.java

示例3: setLogLevel

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
@Override
public void setLogLevel(final String loggerName, final LogLevel logLevel) {
    if (loggerContext != null) {
        final Logger logger = loggerContext.getLogger(loggerName);
        final LoggerConfig config = logger.get();
        final Level level = convert(logLevel);
        if (config.getLevel() != level) {
            config.setLevel(level);
        }
    }
}
 
开发者ID:apache,项目名称:logging-log4j-boot,代码行数:12,代码来源:Log4jLoggingSystem.java

示例4: updateLevel

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
private static void updateLevel(Level level) {
    LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    Configuration config = ctx.getConfiguration();
    LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
    Level curLevel = loggerConfig.getLevel();
    if (curLevel != level) {
        loggerConfig.setLevel(level);
        ctx.updateLoggers();
    }
}
 
开发者ID:visionarts,项目名称:power-jambda,代码行数:11,代码来源:LambdaLoggerHelper.java

示例5: loff

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
protected void loff() {
	LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
	Configuration config = ctx.getConfiguration();
	LoggerConfig loggerConfig = config.getLoggerConfig(ClientCnxn.class.getName());
	cxnLevel = loggerConfig.getLevel();
	loggerConfig.setLevel(Level.ERROR);
	ctx.updateLoggers();		
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:9,代码来源:ZooKeepPublisher.java

示例6: setLogLevel

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static void setLogLevel(Level NewLevel)
{
  LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
  Configuration config = ctx.getConfiguration();
  LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
  Level OldLevel = loggerConfig.getLevel();
  if (OldLevel != NewLevel)
    {
      loggerConfig.setLevel(NewLevel);
      ctx.updateLoggers();  // This causes all Loggers to refetch information from their LoggerConfig.
    }
  if (_originalLogLevel == null)
    _originalLogLevel = OldLevel;
}
 
开发者ID:CapsicoHealth,项目名称:Tilda,代码行数:15,代码来源:LogUtil.java

示例7: addRootApender

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
/**
 * Adds the specified appender to the root logger.
 * 
 * @param appender
 *            the appender
 * @param level
 *            the logging level to assign to the appender. Default is INFO
 */
public static synchronized void addRootApender(Appender appender, String level) {
	Configuration config = getConfiguration();
	appender.start();
	config.addAppender(appender);
	Level l = Level.toLevel(level, Level.INFO);

	LoggerConfig root = config.getRootLogger();
	if (!root.getLevel().isLessSpecificThan(l)) {
		if (originalRootLevel == null) {
			originalRootLevel = root.getLevel();
			Iterator<AppenderRef> it = root.getAppenderRefs().iterator();
			while (it.hasNext()) {
				AppenderRef ar = it.next();
				if (ar.getLevel() == null) {
					Appender a = root.getAppenders().get(ar.getRef());
					root.removeAppender(a.getName());
					root.addAppender(a, originalRootLevel, ar.getFilter());
				}
			}
		}
		root.setLevel(l);
	}
	root.addAppender(appender, l, null);
	addedAppenders++;
	getContext().updateLoggers();
}
 
开发者ID:sfera-labs,项目名称:sfera,代码行数:35,代码来源:LoggerUtils.java

示例8: PrivateConfig

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public PrivateConfig(final PrivateConfig pc, final LoggerConfig lc) {
    this.config = pc.config;
    this.loggerConfig = lc;
    this.level = lc.getLevel();
    this.intLevel = this.level.intLevel();
    this.logger = pc.logger;
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:8,代码来源:Logger.java

示例9: PrivateConfig

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public PrivateConfig(final PrivateConfig pc, final LoggerConfig lc) {
    this.config = pc.config;
    this.loggerConfig = lc;
    this.loggerConfigLevel = lc.getLevel();
    this.intLevel = this.loggerConfigLevel.intLevel();
    this.logger = pc.logger;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:8,代码来源:Logger.java

示例10: getLevel

import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static Level getLevel(String name) {
  LoggerConfig logConfig = getOrCreateLoggerConfig(name);
  return logConfig.getLevel();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:5,代码来源:Configurator.java


注:本文中的org.apache.logging.log4j.core.config.LoggerConfig.getLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。