Logging entry and exit of methods along with param

2019-02-09 05:39发布

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?

I am using Log4Net.

7条回答
三岁会撩人
2楼-- · 2019-02-09 06:27

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#.

查看更多
登录 后发表回答