记录每个方法的执行 [英] Record every method execution

查看:61
本文介绍了记录每个方法的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以记录/记录/监视/查看Java程序内部方法的每次执行.

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

例如:

12:30:12 someMethod("argument")
12:30:12 anotherMethos(1, 2, 3)
12:30:13 finalMethod("invalidInputHere1234")

推荐答案

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

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.

这篇关于记录每个方法的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆