com.jamonapi.log4j
Class Log4jBufferListener

java.lang.Object
  extended by com.jamonapi.JAMonBufferListener
      extended by com.jamonapi.log4j.Log4jBufferListener
All Implemented Interfaces:
CopyJAMonListener, JAMonListener, java.util.EventListener

public class Log4jBufferListener
extends JAMonBufferListener

This class can act as a standard JAMonBufferListener/FIFOBuffer or more interestingly if used with log4j it will put in the Buffer data that although designed to work as a Buffer that displays details unique to log4j, if the monitor does not have a Log4jMonKey, it will fallback to Standard JAMonBufferListener behaviour. This makes it so no problems exist if someone inadvertently assigns a Log4jBufferListener to a non log4j entity.

It will create details of the key details (Label (formattedMessage), LoggerName, Level, Threadname, Exception) followed by lastvalue, active, and the date of the invocation


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jamonapi.JAMonBufferListener
JAMonBufferListener.HeaderInfo
 
Constructor Summary
Log4jBufferListener()
          Constructor that creaates this object with its default name (the class name)
Log4jBufferListener(java.lang.String name)
          Pass in the jamonListener name
Log4jBufferListener(java.lang.String name, BufferList list)
          Name the listener and pass in the jamon BufferList to use
 
Method Summary
 JAMonListener copy()
          Makes a usable copy of this BufferListener
 DetailData getDetailData()
           
 java.lang.String[] getHeader()
          Returns the valid header for display of this buffer
 void processEvent(Monitor mon)
          When this event is fired the monitor will be added to the rolling buffer.
protected  java.lang.Object[] toArray(org.apache.log4j.spi.LoggingEvent event, Monitor mon)
          method that returns an array to use in the Buffer.
 
Methods inherited from class com.jamonapi.JAMonBufferListener
addRow, addRow, getBufferList, getDefaultHeaderInfo, getHeaderInfo, getName, getRowCount, hasData, isEmpty, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4jBufferListener

public Log4jBufferListener()
Constructor that creaates this object with its default name (the class name)


Log4jBufferListener

public Log4jBufferListener(java.lang.String name)
Pass in the jamonListener name


Log4jBufferListener

public Log4jBufferListener(java.lang.String name,
                           BufferList list)
Name the listener and pass in the jamon BufferList to use

Method Detail

processEvent

public void processEvent(Monitor mon)
When this event is fired the monitor will be added to the rolling buffer. If it is a log4j monitor the buffer will be specific to log4j fields (i.e.LoggingEvent info such as threadname, formattedmessage, exception stack trace and a few others. If it is not then the super class's processEvent is called.

Specified by:
processEvent in interface JAMonListener
Overrides:
processEvent in class JAMonBufferListener

toArray

protected java.lang.Object[] toArray(org.apache.log4j.spi.LoggingEvent event,
                                     Monitor mon)
method that returns an array to use in the Buffer. It can return any sortable objects as long as they match what is returned in the getHeader() method.

Parameters:
event -
mon -
Returns:
Object[]

copy

public JAMonListener copy()
Makes a usable copy of this BufferListener

Specified by:
copy in interface CopyJAMonListener
Overrides:
copy in class JAMonBufferListener

getHeader

public java.lang.String[] getHeader()
Returns the valid header for display of this buffer


getDetailData

public DetailData getDetailData()
Overrides:
getDetailData in class JAMonBufferListener