use of org.apache.logging.log4j.Level in project torodb by torodb.
the class Log4jUtils method setLevel.
private static void setLevel(LoggerConfig loggerConfig, LogLevel logLevel) {
Level log4jLevel = Log4jLevelToLogLevelMapper.map(logLevel);
loggerConfig.setLevel(log4jLevel);
}
use of org.apache.logging.log4j.Level in project torodb by torodb.
the class Log4jUtils method setLevel.
private static void setLevel(Logger logger, LogLevel logLevel) {
Level log4jLevel = Log4jLevelToLogLevelMapper.map(logLevel);
logger.setLevel(log4jLevel);
}
use of org.apache.logging.log4j.Level in project hutool by looly.
the class Log4j2Log method log.
@Override
public void log(String fqcn, cn.hutool.log.level.Level level, Throwable t, String format, Object... arguments) {
Level log4j2Level;
switch(level) {
case TRACE:
log4j2Level = Level.TRACE;
break;
case DEBUG:
log4j2Level = Level.DEBUG;
break;
case INFO:
log4j2Level = Level.INFO;
break;
case WARN:
log4j2Level = Level.WARN;
break;
case ERROR:
log4j2Level = Level.ERROR;
break;
default:
throw new Error(StrUtil.format("Can not identify level: {}", level));
}
logIfEnabled(fqcn, log4j2Level, t, format, arguments);
}
use of org.apache.logging.log4j.Level in project oxTrust by GluuFederation.
the class AppInitializer method updateLoggingSeverity.
public void updateLoggingSeverity(@Observes @ConfigurationUpdate AppConfiguration appConfiguration) {
String loggingLevel = appConfiguration.getLoggingLevel();
if (StringHelper.isEmpty(loggingLevel)) {
return;
}
log.info("Setting loggers level to: '{}'", loggingLevel);
LoggerContext loggerContext = LoggerContext.getContext(false);
if (StringHelper.equalsIgnoreCase("DEFAULT", loggingLevel)) {
log.info("Reloadming log4j configuration");
loggerContext.reconfigure();
return;
}
Level level = Level.toLevel(loggingLevel, Level.INFO);
for (org.apache.logging.log4j.core.Logger logger : loggerContext.getLoggers()) {
String loggerName = logger.getName();
if (loggerName.startsWith("org.xdi.service") || loggerName.startsWith("org.xdi.oxauth") || loggerName.startsWith("org.gluu")) {
logger.setLevel(level);
}
}
}
use of org.apache.logging.log4j.Level in project gatk by broadinstitute.
the class UtilsUnitTest method testSetLoggingLevel.
/**
* Test setting the global logging level for Picard, Log4j, MinLog and java.util.logging.
*
* Note that there are three very similar, but not identical, logging level enums from different namespaces
* being used here. The one used by Picard (and Hellbender --verbosity) of type "Log.LogLevel", the parallel
* one used by log4j of type "Level", and the one used by java.utils.logging.
*
*/
@Test
public void testSetLoggingLevel() {
// Query and cache the initial Log4j level in place at the start of the tests so we can restore it at the
// end of the tests. Also, since we're QUERYING the Log4j level, but we're SETTING the level using the
// LoggingUtils API, we also need to verify here that the initial level is one of the narrower set of levels
// that is supported by LoggingUtils, since those are the only ones we can restore through the LoggingUtils API.
Level initialLevel = logger.getLevel();
boolean goodInitialLevel = initialLevel == Level.DEBUG || initialLevel == Level.WARN || initialLevel == Level.ERROR || initialLevel == Level.INFO;
Assert.assertTrue(goodInitialLevel);
// Set and test each supported logging level in turn
LoggingUtils.setLoggingLevel(LogLevel.DEBUG);
Assert.assertTrue(logger.getLevel() == Level.DEBUG);
LoggingUtils.setLoggingLevel(LogLevel.WARNING);
Assert.assertTrue(logger.getLevel() == Level.WARN);
LoggingUtils.setLoggingLevel(LogLevel.ERROR);
Assert.assertTrue(logger.getLevel() == Level.ERROR);
LoggingUtils.setLoggingLevel(LogLevel.INFO);
Assert.assertTrue(logger.getLevel() == Level.INFO);
// Restore the logging level back to the original level in place at the beginning of the test
LoggingUtils.setLoggingLevel(LoggingUtils.levelFromLog4jLevel(initialLevel));
Assert.assertTrue(logger.getLevel() == initialLevel);
}
Aggregations