2010-12-17 19 views
1

我遵循本文中提到的步驟http://dotnetslackers.com/articles/aspnet/Getting-ELMAH-to-work-with-WCF-services.aspx配置WCF服務來設置錯誤日誌記錄由ELMAH。它與wsHttpBinding一起使用Visual Studio網絡服務器,但是當我在IIS(5/6)中託管它並將綁定更改爲basicHttpBinding時,它不會記錄錯誤。我試圖將錯誤信號代碼更改爲「Elmah.ErrorLog.GetDefault(null).Log(new Error(ex));」,如鏈接ELMAH - Exception Logging without having HttpContext所述,但這也沒有幫助。不知道我還需要做什麼。請幫忙。這裏是WCF服務的配置(我嘗試評論和取消註釋aspnetcompatibility,但沒有工作)。如果有一個basicHttpBinding的工作示例,這將是非常有用的。提前致謝。錯誤日誌記錄由ELMAH不工作在IIS中使用basicHttpBinding承載的WCF服務

<system.serviceModel> 
    <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />--> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpEndpointBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="ElmahWCF.Service1Behavior" name="ElmahWCF.Service1"> 
     <endpoint address="" binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpEndpointBinding" 
      name="BasicHttpEndpoint" contract="ElmahWCF.IService1"> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ElmahWCF.Service1Behavior"> 
      <!--To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment--> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!--To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information--> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

回答

2

我發現它是發送郵件,但沒有將錯誤記錄到數據庫。它可能是數據庫的權限問題(儘管我對Windows登錄ID有完全訪問數據庫的權限,並且在Visual Studio Web服務器中託管並使用wsHttpBinding時它的日誌很好)。我將它部署到服務器上,並在應用程序池中使用不同的帳戶進行配置,然後將錯誤成功記錄到數據庫,而無需對文章中的代碼進行任何更改。我仍然不確定爲什麼它不會將錯誤記錄到本地IIS的數據庫(我甚至試圖在web.config中將模擬設置爲true,以便它在登錄時使用我的ID),但這對我來說不是一個大問題,因爲它在部署後可以正常工作。謝謝。

相關問題