0

I am using .net 2.0. I want to generate the logs when the methods are calling (before call and after call) in a particular class. Is it possible in Enterprise Library 2.0 or log4net? or Is there any other way?

4

1 回答 1

1

最简单的方法当然是向每个方法添加代码。我假设您不想这样做。

您应该能够使用 Enterprise Library 3.0 中引入的 Policy Injection Application Block 或 Enterprise Library 4.0 中引入的 Unity Application Block 来完成此操作。我不认为 Enterprise Library 2.0 中内置了任何有用的东西。我从未使用过 log4net,但我怀疑它是否有任何有用的功能。

您还可以查看面向方面的编程工具,例如 PostSharp。

是一篇关于如何使用 Unity 完成此任务的文章。

于 2013-06-07T12:43:16.590 回答