| 68 | 1 package fschmidt.util.log4j; | 
|  | 2 | 
|  | 3 import org.apache.log4j.spi.LoggingEvent; | 
|  | 4 import org.apache.log4j.spi.TriggeringEventEvaluator; | 
|  | 5 | 
|  | 6 | 
|  | 7 public final class CountingEvaluator implements TriggeringEventEvaluator { | 
|  | 8 	private final int limit; | 
|  | 9 	private int count = 0; | 
|  | 10 | 
|  | 11 	public CountingEvaluator(int limit) { | 
|  | 12 		this.limit = limit; | 
|  | 13 	} | 
|  | 14 | 
|  | 15 	public boolean isTriggeringEvent(LoggingEvent event) { | 
|  | 16 		if( ++count < limit ) { | 
|  | 17 			return false; | 
|  | 18 		} else { | 
|  | 19 			count = 0; | 
|  | 20 			return true; | 
|  | 21 		} | 
|  | 22 	} | 
|  | 23 } |