use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class PatternParserTest method testNanoPatternLongChangesNanoClockFactoryMode.
@Test
public void testNanoPatternLongChangesNanoClockFactoryMode() {
final Configuration config = new NullConfiguration();
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
final PatternParser pp = new PatternParser(config, KEY, null);
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
pp.parse("%m");
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
pp.parse("%N");
assertTrue(config.getNanoClock() instanceof SystemNanoClock);
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class PatternParserTest method testNanoPatternShortChangesConfigurationNanoClock.
@Test
public void testNanoPatternShortChangesConfigurationNanoClock() {
final Configuration config = new NullConfiguration();
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
final PatternParser pp = new PatternParser(config, KEY, null);
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
pp.parse("%m");
assertTrue(config.getNanoClock() instanceof DummyNanoClock);
// this changes the config clock
pp.parse("%nano");
assertTrue(config.getNanoClock() instanceof SystemNanoClock);
}
use of org.apache.logging.log4j.core.config.Configuration 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.Configuration in project logging-log4j2 by apache.
the class ShutdownTimeoutConfigurationTest method testShutdownFlag.
@Test
public void testShutdownFlag() {
final Configuration config = context.getConfiguration();
assertNotNull("No configuration", config);
assertEquals(5000, config.getShutdownTimeoutMillis());
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class LateConfigTest method testReconfiguration.
@Test
public void testReconfiguration() throws Exception {
final Configuration cfg = context.getConfiguration();
assertNotNull("No configuration", cfg);
assertTrue("Not set to default configuration", cfg instanceof DefaultConfiguration);
final File file = new File(CONFIG);
final LoggerContext loggerContext = LoggerContext.getContext(null, false, file.toURI());
assertNotNull("No Logger Context", loggerContext);
final Configuration newConfig = loggerContext.getConfiguration();
assertTrue("Configuration not reset", cfg != newConfig);
assertTrue("Reconfiguration failed", newConfig instanceof XmlConfiguration);
context = LoggerContext.getContext(false);
final Configuration sameConfig = context.getConfiguration();
assertTrue("Configuration should not have been reset", newConfig == sameConfig);
}
Aggregations