use of org.apache.logging.log4j.core.filter.Filterable in project logging-log4j2 by apache.
the class PropertiesConfigurationTest method testConsoleAppenderFilter.
@Test
public void testConsoleAppenderFilter() throws Exception {
try (LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
// LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
final Configuration configuration = loggerContext.getConfiguration();
assertNotNull(configuration);
final Appender appender = configuration.getAppender("CONSOLE");
assertNotNull(appender);
final Filterable filterable = (Filterable) appender;
final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
assertNotNull(filter);
assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
}
}
use of org.apache.logging.log4j.core.filter.Filterable in project logging-log4j2 by apache.
the class PropertiesConfigurationTest method testCustomAppenderFilter.
@Test
public void testCustomAppenderFilter() throws Exception {
try (LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/LOG4J2-3281.properties")) {
// LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
final Configuration configuration = loggerContext.getConfiguration();
assertNotNull(configuration);
final Appender appender = configuration.getAppender("CUSTOM");
assertNotNull(appender);
final Filterable filterable = (Filterable) appender;
final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
assertNotNull(filter);
assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
}
}
use of org.apache.logging.log4j.core.filter.Filterable in project logging-log4j2 by apache.
the class PropertiesConfigurationTest method testConsoleAppenderLevelRangeFilter.
@Test
public void testConsoleAppenderLevelRangeFilter() throws Exception {
try (LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/LOG4J2-3326.properties")) {
final Configuration configuration = loggerContext.getConfiguration();
assertNotNull(configuration);
final Appender appender = configuration.getAppender("CUSTOM");
assertNotNull(appender);
final Filterable filterable = (Filterable) appender;
final CompositeFilter filter = (CompositeFilter) filterable.getFilter();
final org.apache.logging.log4j.core.Filter[] filters = filter.getFiltersArray();
final LevelRangeFilter customFilterReal = (LevelRangeFilter) ((FilterWrapper) ((FilterAdapter) filters[0]).getFilter()).getFilter();
assertEquals(Level.ALL, customFilterReal.getMinLevel());
final LevelRangeFilter defaultFilter = (LevelRangeFilter) ((FilterWrapper) ((FilterAdapter) filters[1]).getFilter()).getFilter();
assertEquals(Level.TRACE, defaultFilter.getMinLevel());
}
}
Aggregations