How can i log every method called in a class automatically with log4j

后端 未结 3 1517
粉色の甜心
粉色の甜心 2021-02-02 14:17

I have a class with database calls, and I generally want to log every method called (with arguments) in this class with log4j:

logger.debug(\"foo(id=\"+id+\") in         


        
3条回答
  •  悲哀的现实
    2021-02-02 14:41

    One possible solution would be to use aspectj. Idea would be to attach aspect to every method you wish to log, and perform logging is aspect instead of a method. One example of aspectj logging is right here in stackoverflow.

提交回复
热议问题