Java Code Examples for org.apache.logging.log4j.core.Filter#Result
The following examples show how to use
org.apache.logging.log4j.core.Filter#Result .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IbisThreadFilter.java From iaf with Apache License 2.0 | 6 votes |
@Override public Filter.Result filter(LogEvent event) { if (level == null || event.getLevel().isMoreSpecificThan(level)) return Result.NEUTRAL; String tn = event.getThreadName(); if (tn == null || regex == null) return Result.NEUTRAL; if (regex.matcher(tn).matches()) { return getOnMatch(); } else { return getOnMismatch(); } }
Example 2
Source File: AbstractFilterTest.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@Test public void testUnrolledBackwardsCompatible() { final ConcreteFilter filter = new ConcreteFilter(); final Filter.Result expected = Filter.Result.DENY; verifyMethodsWithUnrolledVarargs(filter, Filter.Result.DENY); filter.testResult = Filter.Result.ACCEPT; verifyMethodsWithUnrolledVarargs(filter, Filter.Result.ACCEPT); }
Example 3
Source File: AbstractFilterTest.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private void verifyMethodsWithUnrolledVarargs(final ConcreteFilter filter, final Filter.Result expected) { final Logger logger = null; final Level level = null; final Marker marker = null; assertEquals(expected, filter.filter(logger, level, marker, "", 1)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8, 9)); assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); }
Example 4
Source File: DefaultConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public FilterComponentBuilder newFilter(final String type, final Filter.Result onMatch, final Filter.Result onMismatch) { return new DefaultFilterComponentBuilder(this, type, onMatch.name(), onMismatch.name()); }
Example 5
Source File: ConfigurationBuilder.java From logging-log4j2 with Apache License 2.0 | 2 votes |
/** * Returns a builder for creating Filters. * @param pluginName The Plugin type of the Filter. * @param onMatch "ACCEPT", "DENY", or "NEUTRAL" * @param onMismatch "ACCEPT", "DENY", or "NEUTRAL" * @return A new FilterComponentBuilder. */ FilterComponentBuilder newFilter(String pluginName, Filter.Result onMatch, Filter.Result onMismatch);