[logback-user] opposite of ThresholdFilter or LevelRangeFilter available?

Ceki Gülcü ceki at qos.ch
Tue Mar 16 18:35:33 CET 2010

No, logback does not offer this functionality although it would be very easy to 
write one. Just copy and paste threshhold filter and inverse the comparison logic.

Here it is:

public class InvertedThresholdFilter extends Filter<ILoggingEvent> {

   Level thresholdLevel;

   public FilterReply decide(ILoggingEvent event) {
     if (!isStarted()) {
       return FilterReply.NEUTRAL;

     int eventLevelInt = event.getLevel().toInt();
     int thresholdLevelInt = thresholdLevel.toInt();
     if (eventLevelInt <= thresholdLevelInt) {
       return FilterReply.NEUTRAL;
     } else {
       return FilterReply.DENY;

   public void setLevel(String level) {
     this.thresholdLevel = Level.toLevel(level);

   public void start() {
     if (this.level != null) {


On 16/03/2010 5:13 PM, Christian Migowski wrote:
> Hi,
> does logback offer some functionality that can be thought of the
> opposite of the ThresholdFilter, i.e. I want an appender to log only
> events with levels BELOW and equal to the level specified.
> With log4j, there is the org.apache.log4j.varia.LevelRangeFilter
> available that can do such things, does something similar exists in
> logback?
> thanks in advance,
> regards,
> christia

More information about the Logback-user mailing list