News: Announcing Perf4J: Performance Analysis for Enterprise Java
Perf4J is a new open-source performance logging, monitoring and analysis library for enterprise Java applications. For developers who are familiar with common Java logging frameworks like log4j, we like to describe Perf4J with an analogy: Perf4J is to System.currentTimeMillis() as log4J is to System.out.println() That is, while developers used to use System.out.println() statements as a sort of "poor-man's logging" before good logging frameworks were available, Perf4J aims to provide a feature complete alternative for using System.currentTimeMillis() to time code blocks and monitor performance. Some highlights of Perf4J's functionality include: * A simple stop watch mechanism for succinct timing statements. * A command line tool for parsing log files that generates aggregated statistics and performance graphs. * Easy integration with the most common logging frameworks and facades: log4j, java.util.logging, Apache Commons Logging and SLF4J. * Custom log4j appenders to generate statistics and graphs in a running application. * The ability to expose performance statistics as JMX attributes, and to send notifications when statistics exceed specified thresholds. * A servlet for exposing performance graphs in a web application. * A Profiled annotation and a set of custom aspects that allow unobstrusive timing statements when coupled with an AOP framework such as AspectJ or Spring AOP. * An extensible architecture. The complete documentation gives lots of examples on how to integrate Perf4J into your code. Download the latest Perf4J version today!
- Posted by: Alexander Devine
- Posted on: January 21 2009 08:04 EST
- Re: Announcing Perf4J: Performance Analysis for Enterprise Java by Luc Dewavrin on January 21 2009 11:52 EST
- Re: Announcing Perf4J: Performance Analysis for Enterprise Java by Alexander Devine on January 21 2009 12:29 EST
- Looks interesting by Juha Palomaki on January 21 2009 11:56 EST
- Multiple Log files by mansoor ashraf on January 21 2009 19:45 EST
- Looks promising by Richard Richter on January 23 2009 06:28 EST
- Looks nice - graph appender seems not to be working by Richard Livingstone on January 30 2009 10:06 EST
- Re: Looks nice - graph appender seems not to be working by Alexander Devine on January 30 2009 20:37 EST
Interesting project, i have used these ideas (log4j appender dedicated to logging performance measures) and AOP interceptions in different projects. One question : does the @Profiled annotation in a Spring context can be used in case of "self-invocation" : for instance, when a bean calls an internal and annotated public method ? IMHO, calls to the profiled method won't produced any measures.
Since Spring AOP is proxy based, "self-invocations", where an object directly calls a method on itself, will NOT be proxied. The Spring documentation gives an explanation of this: http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-understanding-aop-proxies However, if you use AspectJ to weave in the timing aspects (either using the ajc compiler or load-time weaving), then these calls WILL get profiled. In general, I recommend using ajc or load-time weaving if you can because Spring AOP has a couple major limitations in addition to the one you point out: only Spring-managed beans are proxied, and only public methods can be the target of advice. If you already use Spring and you can live with these constraints, then Spring AOP is the easiest way to get running, but otherwise using AspectJ is the way to go. Note, though, that Spring also has some nice support for enabling load-time weaving - see: http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-aj-ltw
This looks interesting. Is it possible to do measurements without annotating the methods with @Profiled?I think it would be pretty nice to keep this stuff completely away from source code and just configure the measurements via Spring/AOP.
Yeah, I completely agree, adding "config only" support is something I plan on adding in the future. I'm not 100% sure of how I'll implement it - I just responded to a previous question about how Spring AOP has some significant limitations since it is proxy-based, so I'll probably end up providing a java agent or instrumenting classloader to do config-only instrumentation first, but doing Spring-only config down the line definitely makes sense.
This looks very interesting. One question though, can i feed multiple log files to the perf4j.jar? In the examples it shows only one files being passed as the command line argument. Thanks
If you don't specify a log file on the command line the jar reads from standard input, so you can pass multiple files like this from a *nix command prompt: cat log1.txt log2.txt | java -jar perf4j-0.9.7.jar or from dos: type log1.txt log2.txt 2>1 | java -jar perf4j-0.9.7.jar
Nice way how to use logging API! :-) We've been thinking about collecting of the performance data just a few days ago and this looks very good indeed.
Looks really nice - I currently use Jamon but this gives the capbility to do graphing and very crucially, expose timings as MBeans - which means I can generate alarms when I exceed my SLAs. It all seems to work fine except for one thing - I can't get the org.perf4j.log4j.GraphingStatisticsAppender to operate as per the developers guide. Nothing gets written to the specified file that is supposed to contain the data for the graphs but I know the tag names are correct for my app because I can log flat stats using org.apache.log4j.FileAppender as per the CoalescingStatistics in the example. Everything as far as I can see is as per the dev guide. Sorry to log this publicly but I can't find any email address for this question ! I'm richard bananasoft net
Hi Richard, You can subscribe to the Perf4J mailing lists here: http://perf4j.codehaus.org/mail-lists.html. If you post the details of your problem to the Users' mailing list I can help you out.