org.perf4j.logback
Class GraphingStatisticsAppender

java.lang.Object
  extended by ch.qos.logback.core.spi.ContextAwareBase
      extended by ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.LoggingEvent>
          extended by org.perf4j.logback.GraphingStatisticsAppender
All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent>, ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.LoggingEvent>, ch.qos.logback.core.spi.LifeCycle, Flushable

public class GraphingStatisticsAppender
extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.LoggingEvent>
implements ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>, Flushable

This appender is designed to be attached to an AsyncCoalescingStatisticsAppender. It takes the incoming GroupedTimingStatistics log messages and uses this data to update a graphical view of the logged statistics. If ANOTHER appender is then attached to this appender then the graph URLs will be written to the appender on a scheduled basis. Alternatively, the graph can be viewed by setting up a GraphingServlet to expose the graph images.

Author:
Alex Devine, Xu Huisheng

Field Summary
protected static Map<String,GraphingStatisticsAppender> APPENDERS_BY_NAME
          This class keeps track of all appenders of this type that have been created.
 
Fields inherited from class ch.qos.logback.core.AppenderBase
layout, name, started
 
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
 
Constructor Summary
GraphingStatisticsAppender()
           
 
Method Summary
 void addAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
           
protected  void append(ch.qos.logback.classic.spi.LoggingEvent event)
           
protected  StatisticsChartGenerator createChartGenerator()
          Helper method creates a new StatisticsChartGenerator based on the options set on this appender.
 void detachAndStopAllAppenders()
           
 boolean detachAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
           
 boolean detachAppender(String name)
           
 void flush()
          This flush method writes the graph, with the data that exists at the time it is calld, to any attached appenders.
static Collection<GraphingStatisticsAppender> getAllGraphingStatisticsAppenders()
          This static method returns an unmodifiable collection of all GraphingStatisticsAppenders that have been created.
 ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> getAppender(String name)
           
static GraphingStatisticsAppender getAppenderByName(String appenderName)
          This static method returns any created GraphingStatisticsAppender by its name.
 StatisticsChartGenerator getChartGenerator()
          Gets the contained StatisticsChartGenerator that is used to generate the graphs.
 int getDataPointsPerGraph()
          The DataPointsPerGraph option is used to specify how much data should be displayed on each graph before it is written to any attached appenders.
 String getGraphType()
          The GraphType option is used to specify the data that should be displayed on the graph.
 String getTagNamesToGraph()
          The TagNamesToGraph option is used to specify which tags should be logged as a data series on the graph.
 boolean isAttached(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
           
 Iterator<ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent>> iteratorForAppenders()
           
 void setDataPointsPerGraph(int dataPointsPerGraph)
          Sets the value of the DataPointsPerGraph option.
 void setGraphType(String graphType)
          Sets the value of the GraphType option.
 void setTagNamesToGraph(String tagNamesToGraph)
          Sets the value of the TagNamesToGraph option.
 void start()
           
 void stop()
           
 
Methods inherited from class ch.qos.logback.core.AppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getFirstFilter, getLayout, getName, isStarted, setLayout, setName, toString
 
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getStatusManager, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
 

Field Detail

APPENDERS_BY_NAME

protected static final Map<String,GraphingStatisticsAppender> APPENDERS_BY_NAME
This class keeps track of all appenders of this type that have been created. This allows static access to the appenders from the org.perf4j.logback.servlet.GraphingServlet class.

Constructor Detail

GraphingStatisticsAppender

public GraphingStatisticsAppender()
Method Detail

getGraphType

public String getGraphType()
The GraphType option is used to specify the data that should be displayed on the graph. Acceptable values are Mean, Min, Max, Count, StdDev and TPS (for transactions per second). Defaults to Mean if not explicitly set.

Returns:
The value of the GraphType option

setGraphType

public void setGraphType(String graphType)
Sets the value of the GraphType option. This must be a valid type, one of Mean, Min, Max, Count, StdDev or TPS (for transactions per second).

Parameters:
graphType - The new value for the GraphType option.

getTagNamesToGraph

public String getTagNamesToGraph()
The TagNamesToGraph option is used to specify which tags should be logged as a data series on the graph. If not specified ALL tags will be drawn on the graph, one series for each tag.

Returns:
The value of the TagNamesToGraph option

setTagNamesToGraph

public void setTagNamesToGraph(String tagNamesToGraph)
Sets the value of the TagNamesToGraph option.

Parameters:
tagNamesToGraph - The new value for the TagNamesToGraph option.

getDataPointsPerGraph

public int getDataPointsPerGraph()
The DataPointsPerGraph option is used to specify how much data should be displayed on each graph before it is written to any attached appenders. Defaults to StatisticsChartGenerator.DEFAULT_MAX_DATA_POINTS.

Returns:
The value of the DataPointsPerGraph option

setDataPointsPerGraph

public void setDataPointsPerGraph(int dataPointsPerGraph)
Sets the value of the DataPointsPerGraph option.

Parameters:
dataPointsPerGraph - The new value for the DataPointsPerGraph option.

start

public void start()
Specified by:
start in interface ch.qos.logback.core.spi.LifeCycle
Overrides:
start in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.LoggingEvent>

stop

public void stop()
Specified by:
stop in interface ch.qos.logback.core.spi.LifeCycle
Overrides:
stop in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.LoggingEvent>

createChartGenerator

protected StatisticsChartGenerator createChartGenerator()
Helper method creates a new StatisticsChartGenerator based on the options set on this appender. By default a GoogleChartGenerator is created, though subclasses may override this method to create a different type of chart generator.

Returns:
A newly created StatisticsChartGenerator.

getChartGenerator

public StatisticsChartGenerator getChartGenerator()
Gets the contained StatisticsChartGenerator that is used to generate the graphs.

Returns:
The StatisticsChartGenerator used by this appender.

getAppenderByName

public static GraphingStatisticsAppender getAppenderByName(String appenderName)
This static method returns any created GraphingStatisticsAppender by its name.

Parameters:
appenderName - the name of the GraphingStatisticsAppender to return
Returns:
the specified GraphingStatisticsAppender, or null if not found

getAllGraphingStatisticsAppenders

public static Collection<GraphingStatisticsAppender> getAllGraphingStatisticsAppenders()
This static method returns an unmodifiable collection of all GraphingStatisticsAppenders that have been created.

Returns:
The collection of GraphingStatisticsAppenders created in this VM.

addAppender

public void addAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
Specified by:
addAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

iteratorForAppenders

public Iterator<ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent>> iteratorForAppenders()
Specified by:
iteratorForAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

getAppender

public ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> getAppender(String name)
Specified by:
getAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

isAttached

public boolean isAttached(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
Specified by:
isAttached in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

detachAndStopAllAppenders

public void detachAndStopAllAppenders()
Specified by:
detachAndStopAllAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

detachAppender

public boolean detachAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.LoggingEvent> appender)
Specified by:
detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

detachAppender

public boolean detachAppender(String name)
Specified by:
detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.LoggingEvent>

append

protected void append(ch.qos.logback.classic.spi.LoggingEvent event)
Specified by:
append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.LoggingEvent>

flush

public void flush()
This flush method writes the graph, with the data that exists at the time it is calld, to any attached appenders.

Specified by:
flush in interface Flushable


Copyright © 2008-2011 perf4j.org. All Rights Reserved.