我已经吨的功能在我的WinForms项目,我用NLOG进行记录。我想有包装与每个功能nlogger.Info(开始)
和 nlogger.Info(结束),所以我会知道在哪个地方发生实际的异常或code目前正在运行的地方。
I have tons of functions in my WinForms project and i'm using NLog for logging. I want to have an ability to wrap each function with nlogger.Info("start")
and nlogger.Info("end")
so i will know in which place actual exception occurred or where the code currently runs.
有一个聪明的办法做到这一点还是我需要从上面放置线我所有的功能?
Is there a smart way to do it or i will need to place lines from above in all of my functions ?
我相信 PostSharp 可以做到这一点为你,并且可以应用在组件级别(通过程序集级别的属性)。不过,我会很谨慎的潜在的性能影响。编写方面应该是pretty的很少。
I believe that PostSharp can do this for you, and can apply at the assembly level (via assembly-level attributes). However, I would be cautious of the potential performance impact. Writing the "aspect" should be pretty minimal.