ch.qos.logback.classic.boolex.OnIntervalEvaluator Maven / Gradle / Ivy
package ch.qos.logback.classic.boolex;
import ch.qos.logback.core.CoreConstants;
/**
*
<evaluator class="ch.qos.logback.classic.boolex.OnIntervalEvaluator">
<interval>${LOG_INTERVAL:-300000}</interval>
</evaluator>
*
*
* 발생 시간 간격에 따라 로그 출력 (기본 값: 300000 (5분), 단위: milliseconds)
*
* @see ch.qos.logback.classic.boolex.JaninoEventEvaluator
*/
public final class OnIntervalEvaluator extends ch.qos.logback.core.boolex.EventEvaluatorBase {
private long interval = 300 * CoreConstants.MILLIS_IN_ONE_SECOND;
private long lastTimeMillis;
@Override
public boolean evaluate(final ch.qos.logback.classic.spi.ILoggingEvent event) throws NullPointerException, ch.qos.logback.core.boolex.EvaluationException {
long currentTimeMillis = System.currentTimeMillis();
boolean evaluate = this.lastTimeMillis + this.interval < currentTimeMillis;
if (evaluate) {
this.lastTimeMillis = currentTimeMillis;
}
return evaluate;
}
/**
* @param interval to set (in milliseconds)
*/
public void setInterval(long interval) {
this.interval = interval;
}
}