当前位置: 首页>>代码示例>>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;未经允许,请勿转载。