use of org.apache.logging.log4j.core.config.LoggerConfig in project logging-log4j2 by apache.
the class AsyncLoggerConfigTest method testIncludeLocationDefaultsToFalse.
@Test
public void testIncludeLocationDefaultsToFalse() {
final LoggerConfig rootLoggerConfig = AsyncLoggerConfig.RootLogger.createLogger(null, "INFO", null, new AppenderRef[0], null, new DefaultConfiguration(), null);
assertFalse("Include location should default to false for async logggers", rootLoggerConfig.isIncludeLocation());
final LoggerConfig loggerConfig = AsyncLoggerConfig.createLogger(null, "INFO", "com.foo.Bar", null, new AppenderRef[0], null, new DefaultConfiguration(), null);
assertFalse("Include location should default to false for async logggers", loggerConfig.isIncludeLocation());
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project gatk by broadinstitute.
the class LoggingUtils method setLog4JLoggingLevel.
private static void setLog4JLoggingLevel(Log.LogLevel verbosity) {
// Now establish the logging level used by log4j by propagating the requested
// logging level to all loggers associated with our logging configuration.
final LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
final Configuration loggerContextConfig = loggerContext.getConfiguration();
final String contextClassName = LoggingUtils.class.getName();
final LoggerConfig loggerConfig = loggerContextConfig.getLoggerConfig(contextClassName);
loggerConfig.setLevel(levelToLog4jLevel(verbosity));
loggerContext.updateLoggers();
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project Anserini by castorini.
the class TrainingDataGenerator method createNewLoggerConfig.
/**
* Dynamically creates a logger configuration with an appender that writes to a file.
* This logger is used to write training data.
*
* @param loggerName the name of the logger to create
* @param outputFilePath the file path to write logs to
* @param patternLayout layout for the logger, if null just display
* the message using DEFAULT_CONVERSION_PATTERN
*/
private static void createNewLoggerConfig(String loggerName, String outputFilePath, String patternLayout) {
// Ignore null output files
if (outputFilePath == null)
return;
// Create a logger to write the training data
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
Layout layout = PatternLayout.createLayout(patternLayout == null ? PatternLayout.DEFAULT_CONVERSION_PATTERN : patternLayout, config, null, StandardCharsets.UTF_8, false, false, null, null);
Appender appender = FileAppender.createAppender(outputFilePath, "false", "false", loggerName, "true", "false", "false", "2000", layout, null, "false", null, config);
appender.start();
config.addAppender(appender);
// Adding reference to the appender
AppenderRef ref = AppenderRef.createAppenderRef(loggerName, null, null);
AppenderRef[] refs = new AppenderRef[] { ref };
LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.TRACE, loggerName, "true", refs, null, config, null);
// Adding appender to logger, and adding logger to context
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);
ctx.updateLoggers();
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project pyramid by cheng-li.
the class IMLLogisticRegressionTest method main.
public static void main(String[] args) throws Exception {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.DEBUG);
ctx.updateLoggers();
test1();
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project pyramid by cheng-li.
the class LogisticRegressionTest method main.
public static void main(String[] args) throws Exception {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.DEBUG);
ctx.updateLoggers();
// test3();
test5();
}
Aggregations