1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.filter;
15
16 import ch.qos.logback.classic.Level;
17 import ch.qos.logback.classic.spi.ILoggingEvent;
18 import ch.qos.logback.core.filter.AbstractMatcherFilter;
19 import ch.qos.logback.core.spi.FilterReply;
20
21
22
23
24
25
26
27
28
29
30
31 public class LevelFilter extends AbstractMatcherFilter<ILoggingEvent> {
32
33 Level level;
34
35 @Override
36 public FilterReply decide(ILoggingEvent event) {
37 if (!isStarted()) {
38 return FilterReply.NEUTRAL;
39 }
40
41 if (event.getLevel().equals(level)) {
42 return onMatch;
43 } else {
44 return onMismatch;
45 }
46 }
47
48 public void setLevel(Level level) {
49 this.level = level;
50 }
51
52 public void start() {
53 if (this.level != null) {
54 super.start();
55 }
56 }
57 }