logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark D. Anderson" <...@discerning.com>
Subject recommended approach to performance instrumentation?
Date Wed, 12 Dec 2001 03:04:46 GMT
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:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message