如何在一个已经开发好的java系统中,为某个功能下的方法,添加用户操作日志呢?没有使用spring,也无法用过滤器,是一个类似C/S结构的系统。
如用户在操作某个功能时,需要在日志中输出 用户名 操作的方法名 操作时间 等
PHP中文网2017-04-18 09:52:50
You can wrap a layer of your own object outside the functional object in the developed system to implement the same interface as the functional object or directly inherit the functional object. That is, use the proxy mode and just add logs to the proxy object yourself.
PHP中文网2017-04-18 09:52:50
1. Using JDK
’s dynamic proxy
2. Adopt CGLIB
bytecode enhancement library
巴扎黑2017-04-18 09:52:50
It means directly adding the log printing function without modifying the source code
迷茫2017-04-18 09:52:50
I have written a log that uses reflection to record information changes. It is very basic, but it needs to be embedded into the original code.