本文整理匯總了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);
}
示例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 );
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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.");
}
示例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);
}
示例13: setLogLevel
import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
@Override
public void setLogLevel(String loggerName, LogLevel logLevel)
{
Configurator.setLevel(loggerName, genericLogLevelToLog4j(logLevel));
}
示例14: setLoggingLevelImpl
import org.apache.logging.log4j.core.config.Configurator; //導入方法依賴的package包/類
private static void setLoggingLevelImpl(Level level) {
Configurator.setLevel("net.parostroj", level);
}