- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.classic.turbo.TurboFilter
-
- All Implemented Interfaces:
ContextAware,LifeCycle
- Direct Known Subclasses:
DuplicateMessageFilter,DynamicThresholdFilter,MatchingFilter,ReconfigureOnChangeFilter
public abstract class TurboFilter extends ContextAwareBase implements LifeCycle
TurboFilter is a specialized filter with a decide method that takes a bunch of parameters instead of a single event object. The latter is cleaner but the first is much more performant.For more information about turbo filters, please refer to the online manual at https://logback.qos.ch/manual/filters.html#TurboFilter
- Author:
- Ceki Gulcu
-
-
Field Summary
-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description TurboFilter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FilterReplydecide(Logger logger, org.slf4j.event.LoggingEvent slf4jEvent)This method is intended to be called via SLF4J's fluent API and more specifically byLogger.log(org.slf4j.event.LoggingEvent slf4jEvent).abstract FilterReplydecide(org.slf4j.Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t)Make a decision based on the multiple parameters passed as arguments.StringgetName()booleanisStarted()voidsetName(String name)voidstart()voidstop()-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Constructor Detail
-
TurboFilter
public TurboFilter()
-
-
Method Detail
-
decide
public abstract FilterReply decide(org.slf4j.Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t)
Make a decision based on the multiple parameters passed as arguments. The returned value should be one of,FilterReply.DENY, orFilterReply.NEUTRAL.FilterReply.ACCEPT- Parameters:
marker-logger-level-format-params-t-- Returns:
-
decide
public FilterReply decide(Logger logger, org.slf4j.event.LoggingEvent slf4jEvent)
This method is intended to be called via SLF4J's fluent API and more specifically by
Logger.log(org.slf4j.event.LoggingEvent slf4jEvent). Derived classes are strongly encouraged to override this method with a better suited and more specialized implementation.The present default implementation translates the given SLF4J
LoggingEventinto the set of parameters required bydecide(Marker, Logger, Level, String, Object[], Throwable)and delegate the decision to that method.Concretely, this method:
- extracts the first marker (if any) from the event's marker list,
- maps the SLF4J level to Logback's
Level, - and forwards the event message, arguments and throwable.
Returns the
FilterReplyproduced bydecide(...), which should be one of DENY, NEUTRAL or ACCEPT.Derived classes are strongly encouraged to override this method with a better suited and more specialized implementation.
- Parameters:
logger- the Logger that is logging the event; non-nullslf4jEvent- the SLF4J logging event to translate and evaluate; may be non-null- Returns:
- the filter decision (
DENY,NEUTRALorACCEPT) - Since:
- 1.5.21
-
-