use of org.apache.logging.log4j.core.config.LoggerConfig in project logging-log4j2 by apache.
the class Log4j1ConfigurationFactoryTest method testFile.
private Layout<?> testFile(final String configResource) throws Exception {
final Configuration configuration = getConfiguration(configResource);
final FileAppender appender = configuration.getAppender("File");
assertNotNull(appender);
assertEquals("target/mylog.txt", appender.getFileName());
//
final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
assertNotNull(loggerConfig);
assertEquals(Level.DEBUG, loggerConfig.getLevel());
configuration.start();
configuration.stop();
return appender.getLayout();
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project logging-log4j2 by apache.
the class LoggerTest method testLevelInheritence.
@Test
public void testLevelInheritence() throws Exception {
final Configuration config = context.getConfiguration();
final LoggerConfig loggerConfig = config.getLoggerConfig("org.apache.logging.log4j.core.LoggerTest");
assertNotNull(loggerConfig);
assertEquals(loggerConfig.getName(), "org.apache.logging.log4j.core.LoggerTest");
assertEquals(loggerConfig.getLevel(), Level.DEBUG);
final Logger localLogger = context.getLogger("org.apache.logging.log4j.core.LoggerTest");
assertTrue("Incorrect level - expected DEBUG, actual " + localLogger.getLevel(), localLogger.getLevel() == Level.DEBUG);
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project logging-log4j2 by apache.
the class PropertiesConfigurationTest method testPropertiesConfiguration.
@Test
public void testPropertiesConfiguration() {
final Configuration config = context.getConfiguration();
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project logging-log4j2 by apache.
the class RollingFilePropertiesTest method testPropertiesConfiguration.
@Test
public void testPropertiesConfiguration() {
final Configuration config = context.getConfiguration();
assertNotNull("No configuration created", config);
assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
final Map<String, Appender> appenders = config.getAppenders();
assertNotNull(appenders);
assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 3);
final Map<String, LoggerConfig> loggers = config.getLoggers();
assertNotNull(loggers);
assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
final Filter filter = config.getFilter();
assertNotNull("No Filter", filter);
assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
final Logger logger = LogManager.getLogger(getClass());
logger.info("Welcome to Log4j!");
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project pyramid by cheng-li.
the class RidgeLogisticTrainerTest 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();
}
Aggregations