當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。