2011-06-22 25 views
1

我在修改传统的asp.net项目。我想包括一些名称空间,类和方法的透明日志记录。用EntLib在ASP.NET中透明记录

我使用EntLib。我可以配置警察注射设置以透明地记录我的应用程序吗我必须做什么才能将所有方法记录在指定的命名空间中?

它是我的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.PolicyInjection.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> 

+0

任何人有反应 –

回答

0

你使用Unity创建和myNameSpace对象注入类?如果是这样,请尝试在映射部分添加一个元素。

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

您还需要添加此此sectionExtension登记:

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