Class FilterBasedTriggeringPolicy
java.lang.Object
org.apache.log4j.rolling.FilterBasedTriggeringPolicy
- All Implemented Interfaces:
TriggeringPolicy, org.apache.log4j.spi.OptionHandler, org.apache.log4j.spi.TriggeringEventEvaluator, org.apache.log4j.xml.UnrecognizedElementHandler
public final class FilterBasedTriggeringPolicy
extends Object
implements TriggeringPolicy, org.apache.log4j.spi.TriggeringEventEvaluator, org.apache.log4j.xml.UnrecognizedElementHandler
FilterBasedTriggeringPolicy determines if rolling should be triggered
by evaluating the current message against a set of filters. Unless a
filter rejects a message, a rolling event will be triggered.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.log4j.spi.FilterThe first filter in the filter chain.private org.apache.log4j.spi.FilterThe last filter in the filter chain. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddFilter(org.apache.log4j.spi.Filter newFilter) Add a filter to end of the filter list.voidClear the filters chain.org.apache.log4j.spi.FilterReturns the head Filter.booleanisTriggeringEvent(org.apache.log4j.Appender appender, org.apache.log4j.spi.LoggingEvent event, String file, long fileLength) Determines if a rollover may be appropriate at this time.booleanisTriggeringEvent(org.apache.log4j.spi.LoggingEvent event) booleanparseUnrecognizedElement(Element element, Properties props)
-
Field Details
-
headFilter
private org.apache.log4j.spi.Filter headFilterThe first filter in the filter chain. Set tonullinitially. -
tailFilter
private org.apache.log4j.spi.Filter tailFilterThe last filter in the filter chain.
-
-
Constructor Details
-
FilterBasedTriggeringPolicy
public FilterBasedTriggeringPolicy()Creates a new FilterBasedTriggeringPolicy.
-
-
Method Details
-
isTriggeringEvent
public boolean isTriggeringEvent(org.apache.log4j.spi.LoggingEvent event) - Specified by:
isTriggeringEventin interfaceorg.apache.log4j.spi.TriggeringEventEvaluator
-
isTriggeringEvent
public boolean isTriggeringEvent(org.apache.log4j.Appender appender, org.apache.log4j.spi.LoggingEvent event, String file, long fileLength) Determines if a rollover may be appropriate at this time. If true is returned, RolloverPolicy.rollover will be called but it can determine that a rollover is not warranted.- Specified by:
isTriggeringEventin interfaceTriggeringPolicy- Parameters:
appender- A reference to the appender.event- A reference to the currently event.file- The filename for the currently active log file.fileLength- Length of the file in bytes.- Returns:
- true if a rollover should occur.
-
addFilter
public void addFilter(org.apache.log4j.spi.Filter newFilter) Add a filter to end of the filter list.- Parameters:
newFilter- filter to add to end of list.
-
clearFilters
public void clearFilters()Clear the filters chain. -
getFilter
public org.apache.log4j.spi.Filter getFilter()Returns the head Filter.- Returns:
- head of filter chain, may be null.
-
activateOptions
public void activateOptions()- Specified by:
activateOptionsin interfaceorg.apache.log4j.spi.OptionHandler
-
parseUnrecognizedElement
- Specified by:
parseUnrecognizedElementin interfaceorg.apache.log4j.xml.UnrecognizedElementHandler- Throws:
Exception
-