登录进入和退出方法与参数自动地?参数、方法

2023-09-04 00:28:10 作者:天青色等烟雨

有没有办法为我补充记录,以便在进入和退出的方法获取与参数一同记录莫名其妙地自动追踪的目的呢?我将如何做到这一点?

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?

我使用log4net的。

I am using Log4Net.

推荐答案

有一个看看:

http://stackoverflow.com/questions/25803/how-do-i-intercept-a-method-call-in-c#25825 http://stackoverflow.com/questions/91635/postsharp-il-weaving-thoughts

另外的搜索,这样的AOP或面向方面编程和PostSharp ...你会得到一些有趣的结果。

Also search SO for 'AOP' or 'Aspect Oriented Programming' and PostSharp...you get some interesting results.