Class TimeFilter
java.lang.Object
org.apache.log4j.spi.Filter
org.apache.log4j.filter.TimeFilter
- All Implemented Interfaces:
org.apache.log4j.spi.OptionHandler
public final class TimeFilter
extends org.apache.log4j.spi.Filter
Filters events that fall within a specified time period
in each day.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate CalendarTimezone.private longEnding offset from midnight in milliseconds.private static final longLength of hour in milliseconds.private static final longLength of minute in milliseconds.private static final longLength of second in milliseconds.private longStarting offset from midnight in milliseconds.Fields inherited from class org.apache.log4j.spi.Filter
ACCEPT, DENY, NEUTRAL, next -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdecide(org.apache.log4j.spi.LoggingEvent event) booleanGets whether an event within the timespan should be accepted or denied.voidsetAcceptOnMatch(boolean acceptOnMatch) Sets whether an event within the timespan should be accepted or denied.voidSet end (exclusive) of time span.voidSet start (inclusive) of time span.voidSet timezone.Methods inherited from class org.apache.log4j.spi.Filter
activateOptions, getNext, setNext
-
Field Details
-
acceptOnMatch
private boolean acceptOnMatch -
start
private long startStarting offset from midnight in milliseconds. -
end
private long endEnding offset from midnight in milliseconds. -
calendar
Timezone. -
HOUR_MS
private static final long HOUR_MSLength of hour in milliseconds.- See Also:
-
MINUTE_MS
private static final long MINUTE_MSLength of minute in milliseconds.- See Also:
-
SECOND_MS
private static final long SECOND_MSLength of second in milliseconds.- See Also:
-
-
Constructor Details
-
TimeFilter
public TimeFilter()Constructor.
-
-
Method Details
-
setStart
Set start (inclusive) of time span.- Parameters:
s- string representation of start time as HH:mm:ss.
-
setEnd
Set end (exclusive) of time span.- Parameters:
s- string representation of end time as HH:mm:ss.
-
setTimeZone
-
setAcceptOnMatch
public void setAcceptOnMatch(boolean acceptOnMatch) Sets whether an event within the timespan should be accepted or denied.- Parameters:
acceptOnMatch- true if matching event should be accepted.
-
getAcceptOnMatch
public boolean getAcceptOnMatch()Gets whether an event within the timespan should be accepted or denied.- Returns:
- true if matching event should be accepted.
-
decide
public int decide(org.apache.log4j.spi.LoggingEvent event) - Specified by:
decidein classorg.apache.log4j.spi.Filter
-