Log4j 1.3alpha-7

org.apache.log4j
Class AppenderSkeleton

java.lang.Object
  extended byorg.apache.log4j.spi.ComponentBase
      extended byorg.apache.log4j.AppenderSkeleton
All Implemented Interfaces:
Appender, Component, OptionHandler
Direct Known Subclasses:
AsyncAppender, DBAppender, JMSAppender, ListAppender, ListModelAppender, MulticastAppender, NullAppender, SMTPAppender, SocketAppender, SocketHubAppender, SoundAppender, SyslogAppender, TelnetAppender, UDPAppender, WriterAppender

public abstract class AppenderSkeleton
extends ComponentBase
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  boolean active
          Is the appender ready for action.
protected  boolean closed
          Is this appender closed?
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  Level threshold
          There is no level threshold filtering by default.
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
protected AppenderSkeleton()
          Deprecated. Provided for compatibility, migrate to AppenderSkeleton(boolean) to indicate whether appender is ready upon construction.
protected AppenderSkeleton(boolean isActive)
          Construct an AppenderSkeleton.
 
Method Summary
 void activateOptions()
          Called to configure appender for use after configuration.
 void addFilter(Filter newFilter)
          Add a filter to end of the filter list.
protected abstract  void append(LoggingEvent event)
          Subclasses of AppenderSkeleton should implement 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 subclasses specific append(org.apache.log4j.spi.LoggingEvent) method.
 void finalize()
          Finalize this appender by calling the derived class' close method.
 ErrorHandler getErrorHandler()
          Deprecated. As of 1.3
 Filter getFilter()
          Returns the head Filter.
 Filter getFirstFilter()
          Return the first filter in the filter chain for this Appender.
 Layout getLayout()
          Returns the layout of this appender.
 String getName()
          Returns the name of this FileAppender.
 Level getThreshold()
          Returns this appenders threshold level.
 boolean isActive()
          Returns true if this appender is working order.
 boolean isAsSevereAsThreshold(Level level)
          Check whether the message level is below the appender's threshold.
 boolean isClosed()
          Returns true if this appender instance is closed.
 void setErrorHandler(ErrorHandler eh)
          Deprecated. As of 1.3
 void setLayout(Layout layout)
          Set the layout for this appender.
 void setName(String name)
          Set the name of this Appender.
 void setThreshold(Level threshold)
          Set the threshold level.
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.log4j.Appender
close, setLoggerRepository
 

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 Level threshold
There is no level threshold filtering by default.


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?


active

protected boolean active
Is the appender ready for action.

Constructor Detail

AppenderSkeleton

protected AppenderSkeleton()
Deprecated. Provided for compatibility, migrate to AppenderSkeleton(boolean) to indicate whether appender is ready upon construction.

Construct an AppenderSkeleton.


AppenderSkeleton

protected AppenderSkeleton(boolean isActive)
Construct an AppenderSkeleton.

Parameters:
isActive - true if appender is ready for use upon construction.
Method Detail

activateOptions

public void activateOptions()
Called to configure appender for use after configuration.

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 implement 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 derived class' close method.

Since:
0.8.4

getErrorHandler

public final ErrorHandler getErrorHandler()
Deprecated. As of 1.3

Return the hardcoded OnlyOnceErrorHandler for this Appender. ErrorHandler's are no longer utilized as of version 1.3.

Specified by:
getErrorHandler in interface Appender
Since:
0.9.0

getFilter

public Filter getFilter()
Returns the head Filter.

Specified by:
getFilter in interface Appender
Returns:
the head Filter or null, if no Filters are present
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.

Specified by:
getLayout in interface Appender

getName

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

Specified by:
getName in interface Appender

getThreshold

public Level getThreshold()
Returns this appenders threshold level. See the setThreshold(org.apache.log4j.Level) method for the meaning of this option.

Since:
1.1

isAsSevereAsThreshold

public boolean isAsSevereAsThreshold(Level level)
Check whether the message level is below the appender's threshold. If 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 subclasses specific append(org.apache.log4j.spi.LoggingEvent) method.

Specified by:
doAppend in interface Appender

isClosed

public boolean isClosed()
Returns true if this appender instance is closed.

Since:
1.3

isActive

public boolean isActive()
Returns true if this appender is working order.

Since:
1.3

setErrorHandler

public final void setErrorHandler(ErrorHandler eh)
Deprecated. As of 1.3

Ignored as of 1.3

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

setThreshold

public void setThreshold(Level 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

Log4j 1.3alpha-7

Copyright 2000-2005 Apache Software Foundation.