本文整理汇总了Java中ch.qos.logback.core.filter.Filter类的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Filter类属于ch.qos.logback.core.filter包,在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAbstractAndConsole
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
* Test abstract functions (using console implementation) and the functions
* of console
*
*/
@Test
public void testAbstractAndConsole() {
BaleenConsoleLoggerBuilder builder = new BaleenConsoleLoggerBuilder(NAME, BaleenLogging.DEFAULT_PATTERN,
new MinMaxFilter(Level.INFO, Level.WARN));
LoggerContext context = new LoggerContext();
Encoder<ILoggingEvent> encoder = new PatternLayoutEncoder();
Appender<ILoggingEvent> appender = builder.build(context, encoder);
assertEquals(NAME, builder.getName());
assertTrue(appender instanceof ConsoleAppender);
assertEquals(encoder, ((ConsoleAppender<ILoggingEvent>) appender).getEncoder());
assertNotNull(appender);
assertEquals(NAME, appender.getName());
Filter<ILoggingEvent> filter = appender.getCopyOfAttachedFiltersList().get(0);
assertTrue(filter instanceof MinMaxFilter);
assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
assertEquals(Level.WARN, ((MinMaxFilter) filter).getMax());
}
示例2: startAndAddFilter
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private void startAndAddFilter(Filter<ILoggingEvent> filter) {
if (filter != null) {
if (!filter.isStarted()) {
filter.start();
}
addFilter(filter);
}
}
示例3: getFilterChainDecision
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
* Loop through the filters in the list. As soon as a filter decides on
* ACCEPT or DENY, then that value is returned. If all of the filters return
* NEUTRAL, then NEUTRAL is returned.
*/
public FilterReply getFilterChainDecision(E event) {
for (Filter<E> f : filterList) {
final FilterReply r = f.decide(event);
if (r == FilterReply.DENY || r == FilterReply.ACCEPT) {
return r;
}
}
return FilterReply.NEUTRAL;
}
示例4: configureFilters
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private List<Filter<ILoggingEvent>> configureFilters(Map<String, Object> config) throws InvalidParameterException {
List<Filter<ILoggingEvent>> filters = new ArrayList<>();
List<String> includeLoggers = yamlToList(config.get("includeLoggers"));
List<String> excludeLoggers = yamlToList(config.get("excludeLoggers"));
if (!includeLoggers.isEmpty()) {
LoggerFilter includeFilter = new LoggerFilter(includeLoggers, false);
filters.add(includeFilter);
}
if (!excludeLoggers.isEmpty()) {
LoggerFilter excludeFilter = new LoggerFilter(excludeLoggers, true);
filters.add(excludeFilter);
}
String minLevelStr = (String) config.get("minLevel");
String maxLevelStr = (String) config.get("maxLevel");
Level minLevel = convertToLevel(minLevelStr);
Level maxLevel = convertToLevel(maxLevelStr);
MinMaxFilter levelFilter = new MinMaxFilter(minLevel, maxLevel);
filters.add(levelFilter);
return filters;
}
示例5: configureLogger
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
private BaleenLoggerBuilder configureLogger(Map<String, Object> config) throws InvalidParameterException {
// Extract the specified configuration parameters
String name = (String) config.get("name");
String pattern = (String) config.getOrDefault("pattern", DEFAULT_PATTERN);
String file = (String) config.get("file");
Boolean rolling = (Boolean) config.getOrDefault("daily", false);
Double maxSize = parseToDouble(config.get("size"));
Integer maxHistory = (Integer) config.get("history");
List<Filter<ILoggingEvent>> filters = configureFilters(config);
// Do we have a name, and if so is it a special case (e.g. console)
if (Strings.isNullOrEmpty(name)) {
LOGGER.warn("Required parameter 'name' not specified for logger - logger will be skipped");
return null;
} else if ("console".equalsIgnoreCase(name)) {
return new BaleenConsoleLoggerBuilder(name, pattern, filters);
} else {
if (Strings.isNullOrEmpty(file)) {
file = name;
}
Optional<Integer> integerMaxSize = Optional.empty();
if (maxSize != null) {
integerMaxSize = Optional.of((int) (maxSize * 1024));
}
return new BaleenFileLoggerBuilder(name, pattern, file, filters, rolling, integerMaxSize, Optional
.ofNullable(maxHistory));
}
}
示例6: testNullFilters
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Test
public void testNullFilters() {
BaleenConsoleLoggerBuilder singleBuilder = new BaleenConsoleLoggerBuilder(BaleenLogging.DEFAULT_PATTERN,
(Filter<ILoggingEvent>) null);
List<Filter<ILoggingEvent>> list = null;
BaleenConsoleLoggerBuilder listBuilder = new BaleenConsoleLoggerBuilder(BaleenLogging.DEFAULT_PATTERN, list);
singleBuilder.build(null, null);
listBuilder.build(null, null);
}
示例7: testAbstractAndConsoleMultipleFilters
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Test
public void testAbstractAndConsoleMultipleFilters() {
BaleenConsoleLoggerBuilder builder = new BaleenConsoleLoggerBuilder(NAME, BaleenLogging.DEFAULT_PATTERN,
Arrays.asList(new MinMaxFilter(Level.INFO, Level.ERROR), new MinMaxFilter(Level.INFO, Level.WARN)));
LoggerContext context = new LoggerContext();
Encoder<ILoggingEvent> encoder = new PatternLayoutEncoder();
Appender<ILoggingEvent> appender = builder.build(context, encoder);
assertEquals(NAME, builder.getName());
assertTrue(appender instanceof ConsoleAppender);
assertEquals(encoder, ((ConsoleAppender<ILoggingEvent>) appender).getEncoder());
assertNotNull(appender);
assertEquals(NAME, appender.getName());
assertEquals(2, appender.getCopyOfAttachedFiltersList().size());
Filter<ILoggingEvent> filter = appender.getCopyOfAttachedFiltersList().get(0);
assertTrue(filter instanceof MinMaxFilter);
assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
assertEquals(Level.ERROR, ((MinMaxFilter) filter).getMax());
filter = appender.getCopyOfAttachedFiltersList().get(1);
assertTrue(filter instanceof MinMaxFilter);
assertEquals(Level.INFO, ((MinMaxFilter) filter).getMin());
assertEquals(Level.WARN, ((MinMaxFilter) filter).getMax());
// TODO: Test that both filters are being applied
}
示例8: getCopyOfAttachedFiltersList
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public List<Filter<ILoggingEvent>> getCopyOfAttachedFiltersList() {
return null;
}
示例9: getCopyOfAttachedFiltersList
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public List<Filter<E>> getCopyOfAttachedFiltersList() {
return null;
}
示例10: LambdaConsoleAppender
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public LambdaConsoleAppender(String pattern, Filter<ILoggingEvent> filter) {
this();
addPattern(pattern);
startAndAddFilter(filter);
}
示例11: addFilter
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public void addFilter(Filter<E> newFilter) {
fai.addFilter(newFilter);
}
示例12: getCopyOfAttachedFiltersList
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public List<Filter<E>> getCopyOfAttachedFiltersList() {
return fai.getCopyOfAttachedFiltersList();
}
示例13: addFilter
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
/**
* Add a filter to end of the filter list.
*/
public void addFilter(Filter<E> newFilter) {
filterList.add(newFilter);
}
示例14: getCopyOfAttachedFiltersList
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
public List<Filter<E>> getCopyOfAttachedFiltersList() {
return new ArrayList<Filter<E>>(filterList);
}
示例15: addFilter
import ch.qos.logback.core.filter.Filter; //导入依赖的package包/类
@Override
public void addFilter(Filter<IAccessEvent> newFilter) {
fai.addFilter(newFilter);
}