开发者

Transparent logging in ASP.NET with EntLib

I'm modifying legacy asp.net project. I want include transparent logging for some namespaces, classes and methods.

I use EntLib. Can I configured Police Injection Settings for transparent logging my app? What I must do for logging all methods in specified namespace?

It' s part of my web.config.

<policyInjection>
<policies>
  <add name="Policy">
    <matchingRules>
      <add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.NamespaceMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Namespace Matching Rule">
        <matches>
          <add match="MyNamespace.*" ignoreCase="true" />
        </matches>
      </add>
    </matchingRules>
    <handlers>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Po开发者_如何学编程licyInjection.LogCallHandler, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        beforeMessage="+++AOP " afterMessage=" AOP+++" name="Logging Call Handler">
        <categories>
          <add name="General" />
        </categories>
      </add>
    </handlers>
  </add>
</policies>


Are you using Unity to create and inject the classes in MyNamespace? If so, try adding an element in your mapping section.

<type type="IMyService" mapTo="MyService">
    <lifetime type="singleton"/>
    <interceptor type="InterfaceInterceptor"/>
    <policyInjection/>
</type>

You'll also need to add this this sectionExtension registration:

<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜