How to log/trace any method call of object in java

10,238

Solution 1

Good tracing tool for Java is BTrace.

Solution 2

You can try some profiler using Java Management Extensions or java agent.

See http://java.sun.com/developer/technicalArticles/releases/j2se15/#mnm

Solution 3

Java Instrumentation?

http://download.oracle.com/javase/6/docs/api/java/lang/instrument/Instrumentation.html

Example:

http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html

Share:
10,238
waldecir
Author by

waldecir

Updated on June 04, 2022

Comments

  • waldecir
    waldecir almost 2 years

    I need some thing like a Python decorator. I need to store some information, specifically the method called, its start time, its end time, and its arguments. I cannot import anything outside of Java 1.5 libraries. Is there some thing like what is available in Python?