Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record every method execution

Tags:

java

Is there any way that I can log / record / monitor / view every execution of a method inside of a Java program.

For example:

12:30:12 someMethod("argument")
12:30:12 anotherMethos(1, 2, 3)
12:30:13 finalMethod("invalidInputHere1234")
like image 620
jSherz Avatar asked May 12 '12 10:05

jSherz


2 Answers

Easy answer: modify the method, and insert logging statements.

Somewhat more complex answer, which works even if you can't modify the method: look into aspect-based programming.

like image 96
Amadan Avatar answered Sep 24 '22 21:09

Amadan


Without modifying the code you could use a debugger or profiler that is able to record any state change, like the Chronon time travelling debugger.

like image 33
Bananeweizen Avatar answered Sep 24 '22 21:09

Bananeweizen