Log4j 0.9.1

org.log4j
Class AppenderSkeleton

java.lang.Object
  |
  +--org.log4j.AppenderSkeleton
All Implemented Interfaces:
Appender, OptionHandler
Direct Known Subclasses:
AsyncAppender, FileAppender, NTEventLogAppender, NullAppender, SocketAppender, SyslogAppender

public abstract class AppenderSkeleton
extends Object
implements Appender, OptionHandler

Abstract super-class of the other appenders in the package. This class provides threashold filtering

Since:
0.8.1
Author:
Ceki Gülcü

Field Summary
protected  boolean closed
          Is this appender closed?
protected  ErrorHandler errorHandler
          It is assumed and enforced that errorHandler is never null.
protected  Filter headFilter
          The first filter in the filter chain.
protected  Layout layout
          The layout variable does not need to be set if the appender implementation has its own layout.
protected  String name
          Appenders are named.
protected  Filter tailFilter
          The last filter in the filter chain.
protected  Priority threshold
          There is no priority threshold filtering by default.
static String THRESHOLD_OPTION
          A string constant used in naming the option for setting the threshold for the appender.
 
Constructor Summary
AppenderSkeleton()
           
 
Method Summary
 void activateOptions()
          Derived appenders should override this method if option structure requires it.
 void addFilter(Filter newFilter)
          Add a filter to end of the filter list.
protected abstract  void append(LoggingEvent event)
          Subclasses of AppenderSkeleton should imlement this method to perform actual logging.
 void clearFilters()
          Clear the filters chain.
 void doAppend(LoggingEvent event)
          This method performs threshold checks and invokes filters before delegating actual logging to the sub-classes specific append(org.log4j.spi.LoggingEvent) method.
 void finalize()
          Finalize this appender by calling the imlenentation's close method.
 ErrorHandler getErrorHandler()
          Return the currently set ErrorHandler for this Appender.
 Filter getFirstFilter()
          Return the first filter in the filter chain for this Appender.
 String getName()
          Returns the name of this FileAppender.
 String[] getOptionStrings()
          Returns the string array {THRESHOLD_OPTION}.
 boolean isAsSevereAsThreshold(Priority priority)
          Check whether the message priority is below the appender's threshold.
 void setErrorHandler(ErrorHandler eh)
          Set the ErrorHandler for this Appender.
 void setLayout(Layout layout)
          Set the layout for this appender.
 void setName(String name)
          Set the name of this Appender.
 void setOption(String key, String value)
          Configurable Appenders should override this method if they admit additional options.
 void setThreshold(Priority threshold)
          Set the threshold priority.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.log4j.Appender
close, requiresLayout
 

Field Detail

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.

threshold

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

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.

tailFilter

protected Filter tailFilter
The last filter in the filter chain.

closed

protected boolean closed
Is this appender closed?

THRESHOLD_OPTION

public static final String THRESHOLD_OPTION
A string constant used in naming the option for setting the threshold for the appender. See also setThreshold method. Current value of this string constant is Threshold.

Note that all option keys are case sensitive.

Constructor Detail

AppenderSkeleton

public AppenderSkeleton()
Method Detail

activateOptions

public void activateOptions()
Derived appenders should override this method if option structure requires it.
Specified by:
activateOptions in interface OptionHandler

addFilter

public void addFilter(Filter newFilter)
Add a filter to end of the filter list.
Specified by:
addFilter in interface Appender
Since:
0.9.0

append

protected abstract void append(LoggingEvent event)
Subclasses of AppenderSkeleton should imlement this method to perform actual logging. See also AppenderSkeleton.doAppend method.
Since:
0.9.0

clearFilters

public void clearFilters()
Clear the filters chain.
Specified by:
clearFilters in interface Appender
Since:
0.9.0

finalize

public void finalize()
Finalize this appender by calling the imlenentation's close method.
Overrides:
finalize in class Object
Since:
0.8.4

getErrorHandler

public ErrorHandler getErrorHandler()
Return the currently set ErrorHandler for this Appender.
Since:
0.9.0

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.

getName

public final String getName()
Returns the name of this FileAppender.
Specified by:
getName in interface Appender

getOptionStrings

public String[] getOptionStrings()
Returns the string array {THRESHOLD_OPTION}.

Configurable Appenders must override this method to return the additional options they accept.

Specified by:
getOptionStrings in interface OptionHandler

isAsSevereAsThreshold

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

doAppend

public void doAppend(LoggingEvent event)
This method performs threshold checks and invokes filters before delegating actual logging to the sub-classes specific append(org.log4j.spi.LoggingEvent) method.
Specified by:
doAppend in interface Appender

setErrorHandler

public void setErrorHandler(ErrorHandler eh)
Set the ErrorHandler for this Appender.
Specified by:
setErrorHandler in interface 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 SocketAppender ignores the layout set here.
Specified by:
setLayout in interface Appender

setName

public void setName(String name)
Set the name of this Appender.
Specified by:
setName in interface Appender

setOption

public void setOption(String key,
                      String value)
Configurable Appenders should override this method if they admit additional options. All classes derived from AppenderSkeleton admit the Threshold option, that is the value of the string constant THRESHOLD_OPTION. See setThreshold(org.log4j.Priority) method for the meaning of this option.
Specified by:
setOption in interface OptionHandler

setThreshold

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

Log4j 0.9.1

Please notify me about new log4j releases.