2012-04-12 19 views
0

でログイン:
私が使用してASP.NET MVC</strong>アプリケーションでAOPを通じて<strong>ロギングを追加しようとしているEntLibポリシーインジェクションブロック+のStructureMap + log4netの

  • エンタープライズライブラリポリシー射出アプリケーションブロック
  • StructureMap
  • log4netの

これは何ですか私が持っている:

web.configファイル

<configSections> 
    <section name="policyInjection" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /> 
    </configSections> 

    <policyInjection> 
    <policies> 
     <add name="Policy"> 
     <matchingRules> 
      <add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.TagAttributeMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
      match="Log" name="Tag Attribute Matching Rule" /> 
     </matchingRules> 
     <handlers> 
      <add type="MyApp.Website.MyLoggingCallHandler, MyApp.Website, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" 
      name="Custom Handler" /> 
     </handlers> 
     </add> 
    </policies> 
    </policyInjection> 

ブートストラップ:

ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory()); 

StructureMapControllerFactory:

public class StructureMapControllerFactory : DefaultControllerFactory 
{ 
    protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) 
    { 
    var instance = ObjectFactory.GetInstance(controllerType); 
    return PolicyInjection.Wrap<IController>(instance); 
    } 
} 

コントローラー:

[Tag("Log")] 
public class HomeController : Controller 
{ 
    //Implementation 
} 

MyLoggingCallHandler:

namespace MyApp.Website 
{ 
    [ConfigurationElementType(typeof(CustomCallHandlerData))] 
    public class MyLoggingCallHandler : ICallHandler 
    { 
     public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) 
     { 
      //Implementation 
     } 

     public int Order { get; set; } 
    } 
} 

問題がある:コールハンドラはを解雇されることはありません。
私は間違っていますか?

答えて

関連する問題