org.apache.logging.log4j.core.appender
Class AppenderBase

java.lang.Object
  extended by org.apache.logging.log4j.core.filter.Filterable
      extended by org.apache.logging.log4j.core.appender.AppenderBase
All Implemented Interfaces:
Appender, Filtering, Lifecycle
Direct Known Subclasses:
FailoverAppender, JMSQueueAppender, JMSTopicAppender, OutputStreamAppender, RewriteAppender, RoutingAppender

public abstract class AppenderBase
extends Filterable
implements Appender, Lifecycle

Base class for Appenders. Although Appenders do not have to extend this class, doing so will simplify their implementation.


Field Summary
protected static Logger LOGGER
          Allow subclasses access to the status logger without creating another instance.
 
Constructor Summary
protected AppenderBase(String name, Filter filter, Layout layout)
          Constructor that defaults to suppressing exceptions.
protected AppenderBase(String name, Filter filter, Layout layout, boolean handleException)
          Constructor.
 
Method Summary
 void close()
          Close the stream associated with the Appender.
 void error(String msg)
          Handle an error with a message.
 void error(String msg, LogEvent event, Throwable t)
          Handle an error with a message, and exception and a logging event.
 void error(String msg, Throwable t)
          Handle an error with a message and an exception.
 ErrorHandler getHandler()
          Return the ErrorHandler, if any.
 Layout getLayout()
          Returns the Layout for the appender.
 String getName()
          Returns the name of the Appender.
 boolean isExceptionSuppressed()
          Some appenders need to propogate exceptions back to the application.
 boolean isStarted()
          Returns true if the Appender is started, false otherwise.
 void setHandler(ErrorHandler handler)
          The handler must be set before the appender is started.
 void start()
          Start the Appender.
 void stop()
          Stop the Appender.
 String toString()
           
 
Methods inherited from class org.apache.logging.log4j.core.filter.Filterable
addFilter, getFilter, hasFilter, isFiltered, removeFilter, startFilter, stopFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.logging.log4j.core.Appender
append
 

Field Detail

LOGGER

protected static final Logger LOGGER
Allow subclasses access to the status logger without creating another instance.

Constructor Detail

AppenderBase

protected AppenderBase(String name,
                       Filter filter,
                       Layout layout)
Constructor that defaults to suppressing exceptions.

Parameters:
name - The Appender name.
filter - The Filter to associate with the Appender.
layout - The layout to use to format the event.

AppenderBase

protected AppenderBase(String name,
                       Filter filter,
                       Layout layout,
                       boolean handleException)
Constructor.

Parameters:
name - The Appender name.
filter - The Filter to associate with the Appender.
layout - The layout to use to format the event.
handleException - If true, exceptions will be logged and suppressed. If false errors will be logged and then passed to the application.
Method Detail

getHandler

public ErrorHandler getHandler()
Return the ErrorHandler, if any.

Specified by:
getHandler in interface Appender
Returns:
The ErrorHandler.

setHandler

public void setHandler(ErrorHandler handler)
The handler must be set before the appender is started.

Specified by:
setHandler in interface Appender
Parameters:
handler - The ErrorHandler to use.

close

public void close()
Close the stream associated with the Appender.


getName

public String getName()
Returns the name of the Appender.

Specified by:
getName in interface Appender
Returns:
The name of the Appender.

getLayout

public Layout getLayout()
Returns the Layout for the appender.

Specified by:
getLayout in interface Appender
Returns:
The Layout used to format the event.

isExceptionSuppressed

public boolean isExceptionSuppressed()
Some appenders need to propogate exceptions back to the application. When suppressException is false the AppenderControl will allow the exception to percolate.

Specified by:
isExceptionSuppressed in interface Appender
Returns:
true if exceptions will be supressed, false otherwise.

start

public void start()
Start the Appender.

Specified by:
start in interface Lifecycle

stop

public void stop()
Stop the Appender.

Specified by:
stop in interface Lifecycle

isStarted

public boolean isStarted()
Returns true if the Appender is started, false otherwise.

Specified by:
isStarted in interface Lifecycle
Returns:
true if the Appender is started, false otherwise.

toString

public String toString()
Overrides:
toString in class Object

error

public void error(String msg)
Handle an error with a message.

Parameters:
msg - The message.

error

public void error(String msg,
                  Throwable t)
Handle an error with a message and an exception.

Parameters:
msg - The message.
t - The Throwable.

error

public void error(String msg,
                  LogEvent event,
                  Throwable t)
Handle an error with a message, and exception and a logging event.

Parameters:
msg - The message.
event - The LogEvent.
t - The Throwable.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.