use of org.apache.log4j.bridge.FilterWrapper in project logging-log4j2 by apache.
the class AbstractBuilder method buildFilters.
protected org.apache.logging.log4j.core.Filter buildFilters(final String level, final Filter filter) {
if (level != null && filter != null) {
final List<org.apache.logging.log4j.core.Filter> filterList = new ArrayList<>();
final org.apache.logging.log4j.core.Filter thresholdFilter = ThresholdFilter.createFilter(OptionConverter.convertLevel(level, Level.TRACE), org.apache.logging.log4j.core.Filter.Result.NEUTRAL, org.apache.logging.log4j.core.Filter.Result.DENY);
filterList.add(thresholdFilter);
Filter f = filter;
while (f != null) {
if (filter instanceof FilterWrapper) {
filterList.add(((FilterWrapper) f).getFilter());
} else {
filterList.add(new FilterAdapter(f));
}
f = f.getNext();
}
return CompositeFilter.createFilters(filterList.toArray(org.apache.logging.log4j.core.Filter.EMPTY_ARRAY));
} else if (level != null) {
return ThresholdFilter.createFilter(OptionConverter.convertLevel(level, Level.TRACE), org.apache.logging.log4j.core.Filter.Result.NEUTRAL, org.apache.logging.log4j.core.Filter.Result.DENY);
} else if (filter != null) {
if (filter instanceof FilterWrapper) {
return ((FilterWrapper) filter).getFilter();
} else {
return new FilterAdapter(filter);
}
}
return null;
}
use of org.apache.log4j.bridge.FilterWrapper in project logging-log4j2 by apache.
the class LevelMatchFilterBuilder method createFilter.
private Filter createFilter(String level, boolean acceptOnMatch) {
Level lvl = Level.ERROR;
if (level != null) {
lvl = Level.toLevel(level, Level.ERROR);
}
org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch ? org.apache.logging.log4j.core.Filter.Result.ACCEPT : org.apache.logging.log4j.core.Filter.Result.DENY;
return new FilterWrapper(LevelMatchFilter.newBuilder().setLevel(lvl).setOnMatch(onMatch).setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL).build());
}
use of org.apache.log4j.bridge.FilterWrapper in project logging-log4j2 by apache.
the class LevelRangeFilterBuilder method createFilter.
private Filter createFilter(String levelMax, String levelMin, boolean acceptOnMatch) {
Level max = Level.FATAL;
Level min = Level.TRACE;
if (levelMax != null) {
max = Level.toLevel(levelMax, Level.FATAL);
}
if (levelMin != null) {
min = Level.toLevel(levelMin, Level.DEBUG);
}
org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch ? org.apache.logging.log4j.core.Filter.Result.ACCEPT : org.apache.logging.log4j.core.Filter.Result.NEUTRAL;
return new FilterWrapper(LevelRangeFilter.createFilter(min, max, onMatch, org.apache.logging.log4j.core.Filter.Result.DENY));
}
Aggregations