[logback-dev] svn commit: r1144 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/filter
noreply.seb at qos.ch
noreply.seb at qos.ch
Thu Dec 21 11:53:05 CET 2006
Author: seb
Date: Thu Dec 21 11:53:05 2006
New Revision: 1144
Added:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/filter/
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java
Log:
Added a LevelFilter that works much like the appender threshold in log4j
It returns the ACCEPT value for events whose level is equal or greater to the user provided level, and DENY otherwise.
Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/filter/LevelFilter.java Thu Dec 21 11:53:05 2006
@@ -0,0 +1,36 @@
+package ch.qos.logback.classic.filter;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
+
+public class LevelFilter extends Filter {
+
+ Level level;
+
+ @Override
+ public FilterReply decide(Object eventObject) {
+ if (!isStarted()) {
+ return FilterReply.NEUTRAL;
+ }
+
+ LoggingEvent event = (LoggingEvent)eventObject;
+
+ if (event.getLevel().isGreaterOrEqual(level)) {
+ return FilterReply.ACCEPT;
+ } else {
+ return FilterReply.DENY;
+ }
+ }
+
+ public void setLevel(String level) {
+ this.level = Level.toLevel(level);
+ }
+
+ public void start() {
+ if (this.level != null) {
+ super.start();
+ }
+ }
+}
More information about the logback-dev
mailing list