public abstract class

AppenderSkeleton

extends Object
implements Appender OptionHandler
java.lang.Object
   ↳ org.apache.log4j.AppenderSkeleton
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Summary

Fields
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 level threshold filtering by default.
Public Constructors
AppenderSkeleton()
Create new instance.
Protected Constructors
AppenderSkeleton(boolean isActive)
Create new instance.
Public Methods
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.
void clearFilters()
Clear the filters chain.
synchronized void doAppend(LoggingEvent event)
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific append(LoggingEvent) method.
void finalize()
Finalize this appender by calling the derived class' close method.
ErrorHandler getErrorHandler()
Return the currently set ErrorHandler for this Appender.
Filter getFilter()
Returns the head Filter.
final Filter getFirstFilter()
Return the first filter in the filter chain for this Appender.
Layout getLayout()
Returns the layout of this appender.
final String getName()
Returns the name of this appender.
Priority getThreshold()
Returns this appenders threshold level.
boolean isAsSevereAsThreshold(Priority priority)
Check whether the message level is below the appender's threshold.
synchronized 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 setThreshold(Priority threshold)
Set the threshold level.
Protected Methods
abstract void append(LoggingEvent event)
Subclasses of AppenderSkeleton should implement this method to perform actual logging.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.log4j.Appender
From interface org.apache.log4j.spi.OptionHandler

Fields

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. Set to null initially.

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 level threshold filtering by default.

Public Constructors

public AppenderSkeleton ()

Create new instance.

Protected Constructors

protected AppenderSkeleton (boolean isActive)

Create new instance. Provided for compatibility with log4j 1.3.

Parameters
isActive true if appender is ready for use upon construction. Not used in log4j 1.2.x.

Public Methods

public void activateOptions ()

Derived appenders should override this method if option structure requires it.

public void addFilter (Filter newFilter)

Add a filter to end of the filter list.

public void clearFilters ()

Clear the filters chain.

public synchronized void doAppend (LoggingEvent event)

This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific append(LoggingEvent) method.

public void finalize ()

Finalize this appender by calling the derived class' close method.

public ErrorHandler getErrorHandler ()

Return the currently set ErrorHandler for this Appender.

public Filter getFilter ()

Returns the head Filter.

Returns
  • the head Filter or null, if no Filters are present

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.

public Layout getLayout ()

Returns the layout of this appender. The value may be null.

public final String getName ()

Returns the name of this appender.

Returns
  • name, may be null.

public Priority getThreshold ()

Returns this appenders threshold level. See the setThreshold(Priority) method for the meaning of this option.

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.

public synchronized void setErrorHandler (ErrorHandler eh)

Set the ErrorHandler for this Appender.

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.

public void setName (String name)

Set the name of this Appender.

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.

Protected Methods

protected abstract void append (LoggingEvent event)

Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.