Permalink
Browse files

copy of stat4j initial release 1.0.0 of 2005 from stat4j.sf.net

  • Loading branch information...
0 parents commit 8a6c9f01a331a581050a666aecca2add32091be2 Jakub Holy committed Oct 15, 2011
Showing with 3,486 additions and 0 deletions.
  1. +155 −0 stat4j/README.txt
  2. +90 −0 stat4j/build.xml
  3. +12 −0 stat4j/contributors/Lara DAbreo/todo.txt
  4. +1 −0 stat4j/contributors/Lara DAbreo/whoami.txt
  5. +41 −0 stat4j/etc/log.properties
  6. +68 −0 stat4j/etc/stat4j.properties
  7. BIN stat4j/ext/junit.jar
  8. BIN stat4j/ext/log4j-1.2.8.jar
  9. +134 −0 stat4j/src/net/sourceforge/stat4j/Alert.java
  10. +49 −0 stat4j/src/net/sourceforge/stat4j/Calculator.java
  11. +74 −0 stat4j/src/net/sourceforge/stat4j/Filter.java
  12. +138 −0 stat4j/src/net/sourceforge/stat4j/Metric.java
  13. +84 −0 stat4j/src/net/sourceforge/stat4j/Reading.java
  14. +210 −0 stat4j/src/net/sourceforge/stat4j/Statistic.java
  15. +151 −0 stat4j/src/net/sourceforge/stat4j/Threshold.java
  16. +68 −0 stat4j/src/net/sourceforge/stat4j/Unit.java
  17. +84 −0 stat4j/src/net/sourceforge/stat4j/calculators/Average.java
  18. +115 −0 stat4j/src/net/sourceforge/stat4j/calculators/CalculatorAdapter.java
  19. +59 −0 stat4j/src/net/sourceforge/stat4j/calculators/Count.java
  20. +56 −0 stat4j/src/net/sourceforge/stat4j/calculators/MaxCount.java
  21. +71 −0 stat4j/src/net/sourceforge/stat4j/calculators/Maximum.java
  22. +69 −0 stat4j/src/net/sourceforge/stat4j/calculators/Minimum.java
  23. +79 −0 stat4j/src/net/sourceforge/stat4j/calculators/Rate.java
  24. +47 −0 stat4j/src/net/sourceforge/stat4j/calculators/RunningCount.java
  25. +64 −0 stat4j/src/net/sourceforge/stat4j/calculators/Simple.java
  26. +61 −0 stat4j/src/net/sourceforge/stat4j/calculators/Sum.java
  27. +127 −0 stat4j/src/net/sourceforge/stat4j/config/ResourceBundleStatisticsFactory.java
  28. +41 −0 stat4j/src/net/sourceforge/stat4j/config/StatisticsFactory.java
  29. +70 −0 stat4j/src/net/sourceforge/stat4j/filter/FilterStatisticMap.java
  30. +340 −0 stat4j/src/net/sourceforge/stat4j/filter/MetricCollector.java
  31. +139 −0 stat4j/src/net/sourceforge/stat4j/filter/RegExpScraper.java
  32. +65 −0 stat4j/src/net/sourceforge/stat4j/log4j/Stat4jAppender.java
  33. +83 −0 stat4j/src/net/sourceforge/stat4j/util/Log.java
  34. +99 −0 stat4j/src/net/sourceforge/stat4j/util/Util.java
  35. +41 −0 stat4j/test/log.properties
  36. +92 −0 stat4j/test/net/sourceforge/stat4j/test/TestDelta.java
  37. +88 −0 stat4j/test/net/sourceforge/stat4j/test/TestRate.java
  38. +116 −0 stat4j/test/net/sourceforge/stat4j/test/TestRunningCount.java
  39. +89 −0 stat4j/test/net/sourceforge/stat4j/test/TestSimple.java
  40. +116 −0 stat4j/test/stat4j.properties
@@ -0,0 +1,155 @@
+Introduction
+============
+
+stat4j is Free Software. stat4j is released under the terms of the
+Apache, version 2.0 license which may be viewed at:
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+What is stat4j?
+===============
+
+stat4j is a a simple,lightweight extension to log4j that allows you to mine your
+logs in real-time for statistical information. It can be used to:
+ .Measure and profile application performance
+ .Report on business level statistics such as the number of widgets sold
+ or the number of users logged into your site
+ .Alert for events that indicate production problems
+
+stat4j may be used by any Java/J2EE application that uses log4j for logging.
+stat4j supports Java 1.4 and above.
+
+Features include:
+ .A log4J appender for intercepting log messages
+ .A metrics engine for filtering and scraping metrics from log messages
+ .Pre-built calculators to dervive statistics using common statistical functions
+ .Threshold based alerting
+ .An RSS Appender for outputing logs and statistics in RSS format
+
+When should you use stat4j?
+=========================
+.When you want to use a lightweight mechanism for measuring application performance or
+ capturing user defined statistics of interest to you or your business
+.When you have a mature application and you dont want to use byte code instrumention or
+ invest in exspensive tools
+.When you have copious log messages and want to leverage these into useful metrics -
+ in real-time
+
+Stat4j is free, production friendly and easy to use. It integrates into your application with
+just one line of configuration.
+
+How does it work? - the 5 second overview
+=========================================
+
+Statistics instrumentation:
+
+Statistics may be derived from events or patterns that occur in a log. For example a user count
+may be derived by incrementing a count whenever a messge "User() has logged in."
+occurs and decremented whenever a log message "User() has logged out" occurs. Statistics may be be derived from
+single (instantaneous) matches or 2 related matches in 2 separate log messages. The unit of measurement
+may be time, memory, occurances or a numeric scraped from the message itself. The stat4j appender
+intercepts logs and filters them for matches against user pre-defined statistic patterns. If a match is
+found then the metric is forwarded into stat4j proper which calculates one or more statistic results.
+Calculations can be simple counts,rates or more complex functions such as min,max or average. Log messages that dont
+match any patterns are simply discarded i.e no extra I/O.
+
+Log filtering and scraping is done using regular expressions.
+
+Alerting:
+
+In addition to statistics derivation stat4j allows you to define simple threshold based alerts.
+for example WARN when number of users > 100 or error rate > 10 errors per sec. Alerts are evaluated
+whenever a statistic is calculated and forwarded to a pre-defined log4j alerts category.
+This can then be logged, sent to JMS, or used to generate an RSS feed.
+
+Project Structure
+=================
+README.txt Project overview
+build.xml Ant build file
+/src stat4j java source
+/test stat4j junit java source and log configuration
+/examples stat4j examples including and log configuration
+/ext external libraries
+/contributors Comments and src from stat4j contributors
+/docs Docs generated by build
+/report unit test report generated by rruning unit tests
+
+Quick Start
+===========
+
+To Build:
+
+stat4j uses ANT to build. Ensure that you have java 1.4+ and ANT installed on you machine.
+
+From the command prompt, cd to the stat4j home directory.
+
+Type "ant list" to get a list of targets to build
+Type "ant compile" to compile stat4j classes
+Type "ant dist" to build the stat4j jar file
+Type "ant test" to runt the stat4j test cases
+Type "ant doc" to build the stat4j documentation
+Type "ant demo" to run the stat4j demonstraton app
+
+To Use:
+
+1) Include the stat4j jar file in the classpath of the application you wish to instrument.
+
+e.g java <myApp class> -classpath "libs/log4j.jar;libs/stat4j.jar"
+
+2) Configure log4j to use stat4j
+
+# Add stat4j Appender
+log4j.appender.stat4j=net.sourceforge.stat4j.log4j.Stat4jAppender
+
+# Set stat4j Appender as the default appender for your target log categories,
+# in this case root. This means all log messages will be sent to
+# the console and stat4j appenders
+log4j.rootCategory=console,stat4j
+
+3) Configure the statistics that you want to measure
+
+stat4j configuration is managed by the stat4j.properties file. This file
+contains the stat4j calculator config and the statistics that you want
+collected.
+
+stat4j will load the stat4j.properties automatically from the classpath when stat4j starts up.
+It is assumed to be at the top of the classpath and so must be present in the
+classpath for your application.
+
+stat4j.properties contains several pre-defined statistics,filters
+and alerts: debug_count,error_count,info_count,debug_rate,error_rate, info_rate and error
+alert.
+
+To add your own statistics simply follow the examples provided and add your statistics
+configuration to stat4j.properties.
+
+For more information on configuring statistics see the user guide under the docs directory.
+
+For examples that use stat4j see the examples directory.
+
+For more information on log4j setup and configuration see:
+
+ http://logging.apache.org/
+
+For more information on ANT see:
+
+ http://ant.apache.org/
+
+Roadmap
+=======
+
+1. RSS Appender
+2. More Calculators
+3. stat4j aspects - to allow statistics collection via AOP
+3. Statistics Reporting (push & pull) via RMI/JMX
+4. XML configuration
+5. User tagging
+6. Statistics UI
+7. Eclipse Plugin
+
+Contacts
+========
+
+stat4j homepage: http://stat4j.sourceforge.net/
+SourceForge project info: http://sourceforge.net/projects/stat4j/
+
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<project basedir="." default="compile" name="stat4j">
+
+ <path id="libs">
+ <fileset dir="ext" includes="*.jar" />
+ </path>
+
+ <target name="init">
+ <property name="version" value="1.0" />
+ <property name="base" value="." />
+ <property name="build" value="build" />
+ <property name="report" value="${build}/report" />
+ <property name="dist" value="dist" />
+ <property name="src" value="src" />
+ <property name="etc" value="etc" />
+ <property name="testsrc" value="test" />
+ <property name="examplesrc" value="examples" />
+ <property name="docs" value="docs" />
+ <property name="apidocs" value="${docs}/api" />
+ <property name="jar.filename" value="stat4j-${version}.jar" />
+ <property name="junit.out.dir.xml" value="${report}/junit/xml" />
+ <property name="junit.out.dir.html" value="${report}/junit/html" />
+ </target>
+
+ <target name="clean" depends="init">
+ <delete dir="${build}" />
+ <delete dir="${dist}" />
+ </target>
+
+ <target name="prepare" depends="init">
+ <mkdir dir="${build}" />
+ <mkdir dir="${build}/classes" />
+ <mkdir dir="${build}/src" />
+
+ <copy todir="${build}/src">
+ <fileset dir="${src}" includes="**/*.java" />
+ </copy>
+
+ <copy todir="${build}/src">
+ <fileset dir="${testsrc}" includes="**/*.java" />
+ </copy>
+
+ <copy todir="${build}/src">
+ <fileset dir="${testsrc}" includes="**/*.java" />
+ </copy>
+
+ </target>
+
+ <target name="compile" depends="prepare">
+ <javac destdir="${build}/classes" srcdir="${build}/src" classpathref="libs" />
+ </target>
+
+ <target name="javadoc" depends="prepare">
+ <mkdir dir="${docs}" />
+ <javadoc sourcepath="${build}/src" destdir="${docs}" packagenames="net.sourceforge.stat4j.*" Author="true" Doctitle="stat4j API Documentation" Use="true" Version="true" Windowtitle="stat4j API" Private="true" classpathref="libs">
+ <tag name="todo" description="To do:" />
+ </javadoc>
+ </target>
+
+ <target name="tests" description="Runs the unit tests" depends="compile">
+ <delete dir="${junit.out.dir.xml}" />
+ <mkdir dir="${junit.out.dir.xml}" />
+ <junit printsummary="yes" haltonfailure="no">
+ <classpath refid="${libs}" />
+ <formatter type="xml" />
+ <batchtest fork="yes" todir="${junit.out.dir.xml}">
+ <fileset dir="${testsrc}" includes="**/*Test.java" />
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="junitreport" description="Create a report for the rest result">
+ <mkdir dir="${junit.out.dir.html}" />
+ <junitreport todir="${junit.out.dir.html}">
+ <fileset dir="${junit.out.dir.xml}">
+ <include name="*.xml" />
+ </fileset>
+ <report format="frames" todir="${junit.out.dir.html}" />
+ </junitreport>
+ </target>
+
+ <target name="dist" depends="compile,javadoc">
+ <mkdir dir="${dist}" />
+ <!-- Jar -->
+ <jar basedir="${build}/classes" jarfile="${dist}/${jar.filename}" />
+ </target>
+
+</project>
@@ -0,0 +1,12 @@
+.Finish build
+ -test cases - run
+ -doc - generate api docs
+ -config files in jar
+.Configuration
+ .split config
+.Add forwarding appender support
+.Demo
+ -demo run scripts
+.Test installation works
+.Create User Guide in HTML
+.Create examples
@@ -0,0 +1 @@
+Project creator an so
@@ -0,0 +1,41 @@
+
+# Development Root Debug Level
+# ======================
+log4j.rootLogger=DEBUG,console
+log4j.logger.stat4j=INFO,console
+log4j.logger.alerts=INFO,console
+log4j.logger.test=DEBUG,stat4j
+log4j.additivity.test=false
+
+
+# Configure the Stat4J appender
+# =========================
+log4j.appender.stat4j=au.com.stat4j.log4j.Stat4jAppender
+log4j.appender.stat4j.layout=org.apache.log4j.PatternLayout
+log4j.appender.stat4j.layout.ConversionPattern=%d %-5p [%c] %x%m\n
+
+# Configure the Console (System.out)
+# =========================
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d %-5p [%c] %x%m\n
+
+
+# Configure the Console (System.err)
+# =========================
+log4j.appender.consoleErr=org.apache.log4j.ConsoleAppender
+log4j.appender.consoleErr.Target=System.err
+log4j.appender.consoleErr.layout=org.apache.log4j.PatternLayout
+log4j.appender.consoleErr.layout.ConversionPattern=%d %-5p [%c] %x%m\n
+
+
+
+# Configure the File Logger
+# =================
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=c:\\temp\\appstats4j.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d %-5p [%c] %x%m%n\n
+
+
@@ -0,0 +1,68 @@
+# ==================================================
+# Stat4J configuration properties file
+# ==================================================
+
+# Log4J category to use for stat4j logs
+logcategory=stat4j
+
+# Default factory for creating statistics and calculators
+factory.name=DefaultFactory
+factory.DefaultFactory.classname=au.com.stat4j.config.ResourceBundleStatisticsFactory
+factory.DefaultFactory.bundle=au.com.stat4j.stat4j
+
+# Scraper default decimal format
+# decimalformat=
+
+# Calculators
+calculator.average.classname=au.com.stat4j.calculators.Average
+calculator.min.classname=au.com.stat4j.calculators.Minimum
+calculator.max.classname=au.com.stat4j.calculators.Maximum
+calculator.rate.classname=au.com.stat4j.calculators.Rate
+calculator.rate.period=1000
+calculator.runningcount.classname=au.com.stat4j.calculators.RunningCount
+calculator.maxcount.classname=au.com.stat4j.calculators.MaxCount
+calculator.simple.classname=au.com.stat4j.calculators.Simple
+calculator.sum.classname=au.com.stat4j.calculators.Sum
+
+# Error Rate
+statistic.ErrorRate.description=Errors per second
+statistic.ErrorRate.calculator=rate
+statistic.ErrorRate.first.match=.*Exception.*
+
+# Error Count
+statistic.ErrorCount.description=Number of errors
+statistic.ErrorCount.calculator=count
+statistic.ErrorRate.first.match=.*Exception.*
+
+# Info Rate
+statistic.InfoRate.description=Errors per second
+statistic.InfoRate.calculator=rate
+statistic.InfoRate.first.match=INFO.*
+
+# Info Count
+statistic.InfoCount.description=Number of errors
+statistic.InfoCount.calculator=count
+statistic.InfoRate.first.match=INFO.*
+
+# Debug Rate
+statistic.DebugRate.description=Errors per second
+statistic.DebugRate.calculator=rate
+statistic.DebugRate.first.match=DEBUG.*
+
+# Debug Count
+statistic.DebugCount.description=Number of errors
+statistic.DebugCount.calculator=count
+statistic.DebugRate.first.match=DEBUG.*
+
+# Alerts
+
+# Error Rate
+alert.ErrorRateIncrease.description=ErrorRate Increase
+alert.ErrorRateIncrease.statistic=ErrorRate
+alert.ErrorRateIncrease.warn= >=15
+alert.ErrorRateIncrease.critical= >=25
+alert.ErrorRateIncrease.category=alerts
+
+
+
+
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 8a6c9f0

Please sign in to comment.