Logging entry and exit of methods along with parameters automagically?

前端 未结 7 621
遇见更好的自我
遇见更好的自我 2021-01-02 04:31

Is there a way for me to add logging so that entering and exiting methods gets logged along with parameters automatically somehow for tracing purposes? How would I do so?

7条回答
  •  悲哀的现实
    2021-01-02 04:51

    You can use open source framework CInject on CodePlex that has a LogInjector to mark entry and exit of a method call.

    Or you can follow the steps mentioned on this article on Intercepting Method Calls using IL and create your own interceptor using Reflection.Emit classes in C#.

提交回复
热议问题