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.
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.
1. Using
JDK
’s dynamic proxy2. Adopt
CGLIB
bytecode enhancement libraryNo filters, but blockers
It means directly adding the log printing function without modifying the source code
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.
Use java reflection.