org.apache.log4j

Class AppenderSkeleton

public abstract class AppenderSkeleton extends Object implements Appender, OptionHandler

Abstract superclass of the other appenders in the package. This class provides the code for common functionality, such as support for threshold filtering and support for general filters.

Since: 0.8.1

Author: Ceki Gülcü

Field Summary
protected booleanclosed
Is this appender closed?
protected ErrorHandlererrorHandler
It is assumed and enforced that errorHandler is never null.
protected FilterheadFilter
The first filter in the filter chain.
protected Layoutlayout
The layout variable does not need to be set if the appender implementation has its own layout.
protected Stringname
Appenders are named.
protected FiltertailFilter
The last filter in the filter chain.
protected Prioritythreshold
There is no level threshold filtering by default.
Method Summary
voidactivateOptions()
Derived appenders should override this method if option structure requires it.
voidaddFilter(Filter newFilter)
Add a filter to end of the filter list.
protected abstract voidappend(LoggingEvent event)
Subclasses of AppenderSkeleton should implement this method to perform actual logging.
voidclearFilters()
Clear the filters chain.
voiddoAppend(LoggingEvent event)
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific {@link AppenderSkeleton#append} method.
voidfinalize()
Finalize this appender by calling the derived class' close method.
ErrorHandlergetErrorHandler()
Return the currently set {@link ErrorHandler} for this Appender.
FiltergetFilter()
Returns the head Filter.
FiltergetFirstFilter()
Return the first filter in the filter chain for this Appender.
LayoutgetLayout()
Returns the layout of this appender.
StringgetName()
Returns the name of this FileAppender.
PrioritygetThreshold()
Returns this appenders threshold level.
booleanisAsSevereAsThreshold(Priority priority)
Check whether the message level is below the appender's threshold.
voidsetErrorHandler(ErrorHandler eh)
Set the {@link ErrorHandler} for this Appender.
voidsetLayout(Layout layout)
Set the layout for this appender.
voidsetName(String name)
Set the name of this Appender.
voidsetThreshold(Priority threshold)
Set the threshold level.

Field Detail

closed

protected boolean closed
Is this appender closed?

errorHandler

protected ErrorHandler errorHandler
It is assumed and enforced that errorHandler is never null.

headFilter

protected Filter headFilter
The first filter in the filter chain. Set to null initially.

layout

protected Layout layout
The layout variable does not need to be set if the appender implementation has its own layout.

name

protected String name
Appenders are named.

tailFilter

protected Filter tailFilter
The last filter in the filter chain.

threshold

protected Priority threshold
There is no level threshold filtering by default.

Method Detail

activateOptions

public void activateOptions()
Derived appenders should override this method if option structure requires it.

addFilter

public void addFilter(Filter newFilter)
Add a filter to end of the filter list.

Since: 0.9.0

append

protected abstract void append(LoggingEvent event)
Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also {@link #doAppend AppenderSkeleton.doAppend} method.

Since: 0.9.0

clearFilters

public void clearFilters()
Clear the filters chain.

Since: 0.9.0

doAppend

public void doAppend(LoggingEvent event)
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific {@link AppenderSkeleton#append} method.

finalize

public void finalize()
Finalize this appender by calling the derived class' close method.

Since: 0.8.4

getErrorHandler

public ErrorHandler getErrorHandler()
Return the currently set {@link ErrorHandler} for this Appender.

Since: 0.9.0

getFilter

public Filter getFilter()
Returns the head Filter.

Since: 1.1

getFirstFilter

public final Filter getFirstFilter()
Return the first filter in the filter chain for this Appender. The return value may be null if no is filter is set.

getLayout

public Layout getLayout()
Returns the layout of this appender. The value may be null.

getName

public final String getName()
Returns the name of this FileAppender.

getThreshold

public Priority getThreshold()
Returns this appenders threshold level. See the {@link #setThreshold} method for the meaning of this option.

Since: 1.1

isAsSevereAsThreshold

public boolean isAsSevereAsThreshold(Priority priority)
Check whether the message level is below the appender's threshold. If there is no threshold set, then the return value is always true.

setErrorHandler

public void setErrorHandler(ErrorHandler eh)
Set the {@link ErrorHandler} for this Appender.

Since: 0.9.0

setLayout

public void setLayout(Layout layout)
Set the layout for this appender. Note that some appenders have their own (fixed) layouts or do not use one. For example, the {@link org.apache.log4j.net.SocketAppender} ignores the layout set here.

setName

public void setName(String name)
Set the name of this Appender.

setThreshold

public void setThreshold(Priority threshold)
Set the threshold level. All log events with lower level than the threshold level are ignored by the appender.

In configuration files this option is specified by setting the value of the Threshold option to a level string, such as "DEBUG", "INFO" and so on.

Since: 0.8.3

Copyright 2000-2005 Apache Software Foundation.