當前位置: 首頁>>代碼示例>>Java>>正文


Java Configurator.setLevel方法代碼示例

本文整理匯總了Java中org.apache.logging.log4j.core.config.Configurator.setLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java Configurator.setLevel方法的具體用法?Java Configurator.setLevel怎麽用?Java Configurator.setLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.logging.log4j.core.config.Configurator的用法示例。


在下文中一共展示了Configurator.setLevel方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureLogging

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
private void configureLogging(LogLevel logLevel) {
    Level log4jLogLevel;
    switch (Objects.requireNonNull(logLevel)) {
        case NORMAL: {
            log4jLogLevel = Level.INFO;
            break;
        }
        case VERBOSE: {
            log4jLogLevel = Level.DEBUG;
            break;
        }
        case TRACE: {
            log4jLogLevel = Level.TRACE;
            break;
        }
        default: {
            throw new IllegalArgumentException("Unknown log level: " + logLevel.name());
        }
    }
    Configurator.setLevel("bt", log4jLogLevel);
}
 
開發者ID:atomashpolskiy,項目名稱:bt,代碼行數:22,代碼來源:CliClient.java

示例2: ServiceCollector

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
public ServiceCollector( Application csapApplication, OsManager osManager,
		int intervalSeconds, boolean publishSummary ) {

	super( csapApplication, osManager, intervalSeconds, publishSummary );

	httpCollector = new HttpCollector( csapApplication, this );

	if ( Application.isRunningOnDesktop() && !csapApplication.isJunit() ) {
		System.err.println( "\n ============= DESKTOP detected - setting logs to ERROR " );
		Configurator.setLevel( ServiceCollector.class.getName(), Level.ERROR );
	}

	timeStampArray_m = jacksonMapper.createArrayNode();
	totalCpuArray = jacksonMapper.createArrayNode();

	setMaxCollectionAllowedInMs( csapApplication
		.lifeCycleSettings()
		.getMaxJmxCollectionMs() );

	scheduleCollection( this );
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:22,代碼來源:ServiceCollector.java

示例3: changeLogLevel

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
/**
 * @param name
 *            the name of the java class or java package to set the log
 *            level for
 * @param logLevelToSet
 *            the log level to set e.g. TRACE, DEBUG, INFO, WARN, ERROR and
 *            FATAL, providing any other value will lead to DEBUG as new log
 *            level
 */
@MCRCommand(syntax = "change log level of {0} to {1}",
    help = "{0} the package or class name for which to change the log level, {1} the log level to set.",
    order = 10)
public static synchronized void changeLogLevel(String name, String logLevelToSet) {
    LOGGER.info("Setting log level for \"{}\" to \"{}\"", name, logLevelToSet);
    Level newLevel = Level.getLevel(logLevelToSet);
    if (newLevel == null) {
        LOGGER.error("Unknown log level \"{}\"", logLevelToSet);
        return;
    }
    Logger log = "ROOT".equals(name) ? LogManager.getRootLogger() : LogManager.getLogger(name);
    if (log == null) {
        LOGGER.error("Could not get logger for \"{}\"", name);
        return;
    }
    LOGGER.info("Change log level from {} to {}", log.getLevel(), newLevel);
    Configurator.setLevel(log.getName(), newLevel);
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:28,代碼來源:MCRLoggingCommands.java

示例4: debugChangeLevelChildLogger

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Test
public void debugChangeLevelChildLogger() {
    // Use logger AND child loggers
    logger.debug("Debug message 1");
    loggerChild.debug("Debug message 1 child");
    loggerGrandchild.debug("Debug message 1 grandchild");
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 3);
    Configurator.setLevel(logger.getName(), Level.OFF);
    logger.debug("Debug message 2");
    loggerChild.debug("Debug message 2 child");
    loggerGrandchild.debug("Debug message 2 grandchild");
    assertEventCount(events, 3);
    Configurator.setLevel(logger.getName(), Level.DEBUG);
    logger.debug("Debug message 3");
    loggerChild.debug("Debug message 3 child");
    loggerGrandchild.debug("Debug message 3 grandchild");
    assertEventCount(events, 6);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:20,代碼來源:LoggerTest.java

示例5: debugChangeLevelsChildLoggers

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Test
public void debugChangeLevelsChildLoggers() {
    final org.apache.logging.log4j.Logger loggerChild = context.getLogger(logger.getName() + ".child");
    // Use logger AND loggerChild
    logger.debug("Debug message 1");
    loggerChild.debug("Debug message 1 child");
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 2);
    Configurator.setLevel(logger.getName(), Level.ERROR);
    Configurator.setLevel(loggerChild.getName(), Level.DEBUG);
    logger.debug("Debug message 2");
    loggerChild.debug("Debug message 2 child");
    assertEventCount(events, 3);
    Configurator.setLevel(logger.getName(), Level.DEBUG);
    logger.debug("Debug message 3");
    loggerChild.debug("Debug message 3 child");
    assertEventCount(events, 5);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:19,代碼來源:LoggerTest.java

示例6: debugChangeLevelsMapChildLoggers

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Test
public void debugChangeLevelsMapChildLoggers() {
    logger.debug("Debug message 1");
    loggerChild.debug("Debug message 1 C");
    loggerGrandchild.debug("Debug message 1 GC");
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 3);
    final Map<String, Level> map = new HashMap<>();
    map.put(logger.getName(), Level.OFF);
    map.put(loggerChild.getName(), Level.DEBUG);
    map.put(loggerGrandchild.getName(), Level.WARN);
    Configurator.setLevel(map);
    logger.debug("Debug message 2");
    loggerChild.debug("Debug message 2 C");
    loggerGrandchild.debug("Debug message 2 GC");
    assertEventCount(events, 4);
    map.put(logger.getName(), Level.DEBUG);
    map.put(loggerChild.getName(), Level.OFF);
    map.put(loggerGrandchild.getName(), Level.DEBUG);
    Configurator.setLevel(map);
    logger.debug("Debug message 3");
    loggerChild.debug("Debug message 3 C");
    loggerGrandchild.debug("Debug message 3 GC");
    assertEventCount(events, 6);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:26,代碼來源:LoggerTest.java

示例7: debugChangeLevel

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Test
public void debugChangeLevel() {
    logger.debug("Debug message 1");
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 1);
    Configurator.setLevel(logger.getName(), Level.OFF);
    logger.debug("Debug message 2");
    assertEventCount(events, 1);
    Configurator.setLevel(logger.getName(), Level.DEBUG);
    logger.debug("Debug message 3");
    assertEventCount(events, 2);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:13,代碼來源:LoggerTest.java

示例8: debugChangeLevelsMap

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Test
public void debugChangeLevelsMap() {
    logger.debug("Debug message 1");
    final List<LogEvent> events = app.getEvents();
    assertEventCount(events, 1);
    final Map<String, Level> map = new HashMap<>();
    map.put(logger.getName(), Level.OFF);
    Configurator.setLevel(map);
    logger.debug("Debug message 2");
    assertEventCount(events, 1);
    map.put(logger.getName(), Level.DEBUG);
    Configurator.setLevel(map);
    logger.debug("Debug message 3");
    assertEventCount(events, 2);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:16,代碼來源:LoggerTest.java

示例9: before

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Before
public void before() {
    Configurator.setRootLevel(Level.ERROR);
    Configurator.setLevel("io.linuxserver", Level.ERROR);
}
 
開發者ID:linuxserver,項目名稱:davos,代碼行數:6,代碼來源:Logging.java

示例10: enableDebug

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
public static void enableDebug() {
    Configurator.setLevel("io.linuxserver", Level.DEBUG);
    LOGGER.debug("DEBUG has been enabled");
}
 
開發者ID:linuxserver,項目名稱:davos,代碼行數:5,代碼來源:LoggingManager.java

示例11: disableDebug

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
public static void disableDebug() {
    Configurator.setLevel("io.linuxserver", Level.INFO);
    LOGGER.info("DEBUG has been disabled. Back at INFO.");
}
 
開發者ID:linuxserver,項目名稱:davos,代碼行數:5,代碼來源:LoggingManager.java

示例12: setLogLevel

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
public static void setLogLevel(Level level) {
    LOGGER.info("Logging level now set at {}", level);
    Configurator.setLevel("io.linuxserver", level);
}
 
開發者ID:linuxserver,項目名稱:davos,代碼行數:5,代碼來源:LoggingManager.java

示例13: setLogLevel

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Override
public void setLogLevel(String loggerName, LogLevel logLevel)
{
    Configurator.setLevel(loggerName, genericLogLevelToLog4j(logLevel));
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:6,代碼來源:Log4j2LoggingHelper.java

示例14: setLoggingLevelImpl

import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
private static void setLoggingLevelImpl(Level level) {
    Configurator.setLevel("net.parostroj", level);
}
 
開發者ID:jub77,項目名稱:grafikon,代碼行數:4,代碼來源:Main.java


注:本文中的org.apache.logging.log4j.core.config.Configurator.setLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。