org.apache.log4j.varia
Class ListAppender

java.lang.Object
  extended by org.apache.log4j.spi.ComponentBase
      extended by org.apache.log4j.AppenderSkeleton
          extended by org.apache.log4j.varia.ListAppender
All Implemented Interfaces:
Appender, Component, OptionHandler

public final class ListAppender
extends AppenderSkeleton

A very basic appender that takes the events and stores them in to a java.util.List for late retrieval. Note: This implemenation intentionally does not allow direct modification of the internal List model to reduce the synchronization complexity that this would require.

Author:
Paul Smith
See Also:
ListModelAppender

Field Summary
private  java.util.List list
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
active, closed, headFilter, layout, name, tailFilter, threshold
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
ListAppender()
          Constructs a list appender.
 
Method Summary
protected  void append(LoggingEvent event)
          Subclasses of AppenderSkeleton should implement this method to perform actual logging.
 void clearList()
          Removes all the Events from the model
 void close()
          Release any resources allocated within the appender such as file handles, network connections, etc.
 java.util.List getList()
          Returns a writeable, BUT cloned List of all the LoggingEvents that are contained in the internal model.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activate, activateOptions, addFilter, clearFilters, doAppend, finalize, getFilter, getFirstFilter, getLayout, getName, getThreshold, isActive, isAsSevereAsThreshold, isClosed, setLayout, setName, setThreshold
 
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
setLoggerRepository
 

Field Detail

list

private java.util.List list
Constructor Detail

ListAppender

public ListAppender()
Constructs a list appender.

Method Detail

getList

public final java.util.List getList()
Returns a writeable, BUT cloned List of all the LoggingEvents that are contained in the internal model. You are free to modify this list without worry of synchronization, but note that any modifications to the returned list that you do will have NO impact on the internal model of this Appender.

Returns:
Modifiable List

append

protected void append(LoggingEvent event)
Description copied from class: AppenderSkeleton
Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.

Specified by:
append in class AppenderSkeleton

close

public void close()
Description copied from interface: Appender
Release any resources allocated within the appender such as file handles, network connections, etc.

It is a programming error to append to a closed appender.


clearList

public void clearList()
Removes all the Events from the model