ELMAH使用basicHttpBinding在IIS托管的WCF服务中不工作时记录错误
我按照本文中提到的步骤将WCF服务配置为通过ELMAH设置错误日志记录。它与VisualStudioWebServer的wsHttpBinding一起工作,但是当我在IIS(5/6)中托管它并将绑定更改为basicHttpBinding时,它不会记录错误。我试图将错误信号代码更改为“ELMAH使用basicHttpBinding在IIS托管的WCF服务中不工作时记录错误,wcf,exception-handling,error-handling,elmah,Wcf,Exception Handling,Error Handling,Elmah,我按照本文中提到的步骤将WCF服务配置为通过ELMAH设置错误日志记录。它与VisualStudioWebServer的wsHttpBinding一起工作,但是当我在IIS(5/6)中托管它并将绑定更改为basicHttpBinding时,它不会记录错误。我试图将错误信号代码更改为“Elmah.ErrorLog.GetDefault(null.Log)(新错误(ex));”,正如在这个链接中提到的,但也没有帮助。不知道我还需要做什么。请帮忙。下面是WCF服务的配置(我也尝试过对aspnetcom
Elmah.ErrorLog.GetDefault(null.Log)(新错误(ex));
”,正如在这个链接中提到的,但也没有帮助。不知道我还需要做什么。请帮忙。下面是WCF服务的配置(我也尝试过对aspnetcompatibility进行注释和取消注释,但没有成功)。如果有一个使用basicHttpBinding的工作示例,那将非常有用。提前谢谢
<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>
我发现它正在发送邮件,但没有将错误记录到数据库中。这可能是数据库的权限问题(即使我对数据库拥有windows登录Id的完全访问权限,并且在visual studio webserver中托管并使用wsHttpBinding时,它的日志记录良好)。我将它部署到服务器上,并在应用程序池中配置了不同的帐户,之后它将成功地将错误记录到数据库中,而无需对文章中的代码进行任何更改。我仍然不确定为什么它不将错误从本地IIS记录到数据库中(我甚至尝试在web.config中将模拟设置为true,以便它在记录时使用我的id),但这对我来说不是什么大问题,因为它在部署后可以正常工作。谢谢