记录每个方法执行

jSh*_*erz 5 java

有没有办法可以记录/记录/监视/查看Java程序内每个方法的执行.

例如:

12:30:12 someMethod("argument")
12:30:12 anotherMethos(1, 2, 3)
12:30:13 finalMethod("invalidInputHere1234")
Run Code Online (Sandbox Code Playgroud)

Ama*_*dan 3

简单的答案:修改方法,并插入日志记录语句。

稍微复杂一点的答案,即使您无法修改该方法,它仍然有效:研究基于方面的编程。

  • 看看[这篇文章](http://mathewjhall.wordpress.com/2011/03/31/tracing-java-method-execution-with-aspectj/) (2认同)