Package org.apache.log4j
Class AppenderSkeleton
- java.lang.Object
-
- org.apache.log4j.AppenderSkeleton
-
- All Implemented Interfaces:
Appender,OptionHandler
- Direct Known Subclasses:
AsyncAppender,JDBCAppender,JMSAppender,NullAppender,RewriteAppender,SMTPAppender,SocketAppender,SocketHubAppender,SyslogAppender,TelnetAppender,WriterAppender
public abstract class AppenderSkeleton extends java.lang.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
Fields Modifier and Type Field Description protected booleanclosedIs this appender closed?protected ErrorHandlererrorHandlerIt is assumed and enforced that errorHandler is never null.protected FilterheadFilterThe first filter in the filter chain.protected LayoutlayoutThe layout variable does not need to be set if the appender implementation has its own layout.protected java.lang.StringnameAppenders are named.protected FiltertailFilterThe last filter in the filter chain.protected PrioritythresholdThere is no level threshold filtering by default.
-
Constructor Summary
Constructors Modifier Constructor Description AppenderSkeleton()Create new instance.protectedAppenderSkeleton(boolean isActive)Create new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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 ofAppenderSkeletonshould 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 specificappend(org.apache.log4j.spi.LoggingEvent)method.voidfinalize()Finalize this appender by calling the derived class'closemethod.ErrorHandlergetErrorHandler()Return the currently setErrorHandlerfor 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.java.lang.StringgetName()Returns the name of this appender.PrioritygetThreshold()Returns this appenders threshold level.booleanisAsSevereAsThreshold(Priority priority)Check whether the message level is below the appender's threshold.voidsetErrorHandler(ErrorHandler eh)Set theErrorHandlerfor this Appender.voidsetLayout(Layout layout)Set the layout for this appender.voidsetName(java.lang.String name)Set the name of this Appender.voidsetThreshold(Priority threshold)Set the threshold level.-
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, 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 java.lang.String name
Appenders are named.
-
threshold
protected Priority threshold
There is no level 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 tonullinitially.
-
tailFilter
protected Filter tailFilter
The last filter in the filter chain.
-
closed
protected boolean closed
Is this appender closed?
-
-
Constructor Detail
-
AppenderSkeleton
public AppenderSkeleton()
Create new instance.
-
AppenderSkeleton
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.- Since:
- 1.2.15
-
-
Method Detail
-
activateOptions
public void activateOptions()
Derived appenders should override this method if option structure requires it.- Specified by:
activateOptionsin interfaceOptionHandler
-
addFilter
public void addFilter(Filter newFilter)
Add a filter to end of the filter list.
-
append
protected abstract void append(LoggingEvent event)
Subclasses ofAppenderSkeletonshould implement this method to perform actual logging. See alsoAppenderSkeleton.doAppendmethod.- Since:
- 0.9.0
-
clearFilters
public void clearFilters()
Clear the filters chain.- Specified by:
clearFiltersin interfaceAppender- Since:
- 0.9.0
-
finalize
public void finalize()
Finalize this appender by calling the derived class'closemethod.- Overrides:
finalizein classjava.lang.Object- Since:
- 0.8.4
-
getErrorHandler
public ErrorHandler getErrorHandler()
Return the currently setErrorHandlerfor this Appender.- Specified by:
getErrorHandlerin interfaceAppender- Since:
- 0.9.0
-
getFilter
public Filter getFilter()
Returns the head Filter.
-
getFirstFilter
public final Filter getFirstFilter()
Return the first filter in the filter chain for this Appender. The return value may benullif no is filter is set.
-
getLayout
public Layout getLayout()
Returns the layout of this appender. The value may be null.
-
getName
public final java.lang.String getName()
Returns the name of this appender.
-
getThreshold
public Priority getThreshold()
Returns this appenders threshold level. See thesetThreshold(org.apache.log4j.Priority)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 alwaystrue.
-
doAppend
public void doAppend(LoggingEvent event)
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specificappend(org.apache.log4j.spi.LoggingEvent)method.
-
setErrorHandler
public void setErrorHandler(ErrorHandler eh)
Set theErrorHandlerfor this Appender.- Specified by:
setErrorHandlerin interfaceAppender- 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, theSocketAppenderignores the layout set here.
-
setName
public void setName(java.lang.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
-
-