You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Mark D. Anderson" <md...@discerning.com> on 2001/12/12 04:04:46 UTC
recommended approach to performance instrumentation?
suppose i want to log timing information in a server for handling of client requests.
i'd like to be able to instrument the code something like this:
static Category perflog_ = Category.getInstance(MyClass.class);
....
handle_request(String user_id, String request_type, String message_id, [...]) {
Object handle = perflog_.begin("handle_request", user_id, request_type, message_id);
...
// log the end of that timing interval. handle is for efficiency and to eliminate chance
// of ambiguity.
// not reliable in the face of exceptions, though in principle the handle could eventually
// detect this in its finalizer.
perflog_.end(handle);
...
// time whole thing -- will catch and re-throw any exception
Runnable something = new MyRunnable();
perflog_.timerun("handle_request", user_id, request_type, message_id, something);
}
surely someone has done something like this?
hopefully with a post-processor that generates appropriate reports?
perhaps the NDC or MDC would help here?
i can't tell; the log4j documentation is sorely in need of a cookbook....
-mda
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>