Package org.apache.log4j.chainsaw
Class ChainsawAppenderHandler
- java.lang.Object
-
- org.apache.log4j.AppenderSkeleton
-
- org.apache.log4j.chainsaw.ChainsawAppenderHandler
-
- All Implemented Interfaces:
org.apache.log4j.Appender,org.apache.log4j.spi.OptionHandler
public class ChainsawAppenderHandler extends org.apache.log4j.AppenderSkeletonA handler class that either extends a particular appender hierarchy or can be bound into the Log4j appender framework, and queues events, to be later dispatched to registered/interested parties.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classChainsawAppenderHandler.WorkQueueQueue of Events are placed in here, which are picked up by an asychronous thread.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,org.apache.log4j.rule.Rule>customExpressionRulesprivate doubledataRateprivate static java.lang.StringDEFAULT_IDENTIFIERprivate java.lang.StringidentifierExpressionprivate javax.swing.event.EventListenerListlistenerListprivate java.lang.Objectmutexprivate java.beans.PropertyChangeSupportpropertySupportprivate org.apache.log4j.spi.LoggingEventFieldResolverresolverprivate intsleepIntervalprivate ChainsawAppenderHandler.WorkQueueworkerNOTE: This variable needs to be physically located LAST, because of the initialization sequence, the WorkQueue constructor starts a thread which ends up needing some reference to fields created in ChainsawAppenderHandler (outer instance) which may not have been created yet.
-
Constructor Summary
Constructors Constructor Description ChainsawAppenderHandler()ChainsawAppenderHandler(ChainsawAppender appender)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCustomEventBatchListener(java.lang.String identifier, EventBatchListener l)voidaddEventBatchListener(EventBatchListener l)voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)voidappend(org.apache.log4j.spi.LoggingEvent event)voidclose()doublegetDataRate()Exposes the current Data rate calculated.java.lang.StringgetIdentifierExpression()intgetQueueInterval()(package private) java.lang.StringgetTabIdentifier(org.apache.log4j.spi.LoggingEvent e)Determines an appropriate title for the Tab for the Tab Pane by locating a the hostname propertyvoidremoveEventBatchListener(EventBatchListener l)voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)voidremovePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)booleanrequiresLayout()(package private) voidsetDataRate(double dataRate)voidsetIdentifierExpression(java.lang.String identifierExpression)voidsetQueueInterval(int interval)
-
-
-
Field Detail
-
DEFAULT_IDENTIFIER
private static final java.lang.String DEFAULT_IDENTIFIER
- See Also:
- Constant Field Values
-
mutex
private final java.lang.Object mutex
-
sleepInterval
private int sleepInterval
-
listenerList
private javax.swing.event.EventListenerList listenerList
-
dataRate
private double dataRate
-
identifierExpression
private java.lang.String identifierExpression
-
resolver
private final org.apache.log4j.spi.LoggingEventFieldResolver resolver
-
propertySupport
private java.beans.PropertyChangeSupport propertySupport
-
customExpressionRules
private java.util.Map<java.lang.String,org.apache.log4j.rule.Rule> customExpressionRules
-
worker
private ChainsawAppenderHandler.WorkQueue worker
NOTE: This variable needs to be physically located LAST, because of the initialization sequence, the WorkQueue constructor starts a thread which ends up needing some reference to fields created in ChainsawAppenderHandler (outer instance) which may not have been created yet. Becomes a race condition, and therefore this field initialization should be kept last.
-
-
Constructor Detail
-
ChainsawAppenderHandler
public ChainsawAppenderHandler(ChainsawAppender appender)
-
ChainsawAppenderHandler
public ChainsawAppenderHandler()
-
-
Method Detail
-
setIdentifierExpression
public void setIdentifierExpression(java.lang.String identifierExpression)
-
getIdentifierExpression
public java.lang.String getIdentifierExpression()
-
addCustomEventBatchListener
public void addCustomEventBatchListener(java.lang.String identifier, EventBatchListener l) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
addEventBatchListener
public void addEventBatchListener(EventBatchListener l)
-
removeEventBatchListener
public void removeEventBatchListener(EventBatchListener l)
-
append
public void append(org.apache.log4j.spi.LoggingEvent event)
- Specified by:
appendin classorg.apache.log4j.AppenderSkeleton
-
close
public void close()
-
requiresLayout
public boolean requiresLayout()
-
getQueueInterval
public int getQueueInterval()
-
setQueueInterval
public void setQueueInterval(int interval)
-
getTabIdentifier
java.lang.String getTabIdentifier(org.apache.log4j.spi.LoggingEvent e)
Determines an appropriate title for the Tab for the Tab Pane by locating a the hostname property- Parameters:
e-- Returns:
- identifier
-
getDataRate
public double getDataRate()
Exposes the current Data rate calculated. This is periodically updated by an internal Thread as is the number of events that have been processed, and dispatched to all listeners since the last sample period divided by the number of seconds since the last sample period.This method fires a PropertyChange event so listeners can monitor the rate
- Returns:
- double # of events processed per second
-
setDataRate
void setDataRate(double dataRate)
- Parameters:
dataRate-
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Parameters:
listener-
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)- Parameters:
propertyName-listener-
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
- Parameters:
listener-
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)- Parameters:
propertyName-listener-
-
-