use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class ShutdownDisabledTest method testShutdownFlag.
@Test
public void testShutdownFlag() {
final Configuration config = context.getConfiguration();
assertNotNull("No configuration", config);
assertFalse("Shutdown hook is enabled", config.isShutdownHookEnabled());
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class PropertiesConfigurationRootLoggerOnlyTest 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() == 1);
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.Configuration in project logging-log4j2 by apache.
the class StructuredDataFilterTest method testConfig.
@Test
public void testConfig() {
final Configuration config = context.getConfiguration();
final Filter filter = config.getFilter();
assertNotNull("No StructuredDataFilter", filter);
assertTrue("Not a StructuredDataFilter", filter instanceof StructuredDataFilter);
final StructuredDataFilter sdFilter = (StructuredDataFilter) filter;
assertFalse("Should not be And filter", sdFilter.isAnd());
final Map<String, List<String>> map = sdFilter.getMap();
assertNotNull("No Map", map);
assertFalse("No elements in Map", map.isEmpty());
assertEquals("Incorrect number of elements in Map", 1, map.size());
assertTrue("Map does not contain key eventId", map.containsKey("eventId"));
assertEquals("List does not contain 2 elements", 2, map.get("eventId").size());
}
use of org.apache.logging.log4j.core.config.Configuration in project geode by apache.
the class LogService method isUsingGemFireDefaultConfig.
public static boolean isUsingGemFireDefaultConfig() {
final Configuration config = ((org.apache.logging.log4j.core.Logger) LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
final StrSubstitutor sub = config.getStrSubstitutor();
final StrLookup resolver = sub.getVariableResolver();
final String value = resolver.lookup(GEMFIRE_DEFAULT_PROPERTY);
return "true".equals(value);
}
use of org.apache.logging.log4j.core.config.Configuration in project geode by apache.
the class Configurator method getLoggerConfig.
public static LoggerConfig getLoggerConfig(final String name) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
LoggerConfig logConfig = config.getLoggerConfig(name);
if (!logConfig.getName().equals(name)) {
throw new IllegalStateException("LoggerConfig does not exist for " + name);
}
return logConfig;
}
Aggregations