ELMAH 的错误日志记录无法在 IIS 中使用 basicHttpBinding 托管的 WCF 服务中工作

发布于 2024-10-07 18:33:10 字数 2267 浏览 0 评论 0原文

我按照本文中提到的步骤 http: //dotnetslackers.com/articles/aspnet/Getting-ELMAH-to-work-with-WCF-services.aspx 配置 WCF 服务以通过 ELMAH 设置错误日志记录。它与 Visual Studio Web 服务器的 wsHttpBinding 一起使用,但是当我将其托管在 IIS (5/6) 中并将绑定更改为 basicHttpBinding 时,它不会记录错误。我尝试将错误信号代码更改为“Elmah.ErrorLog.GetDefault(null).Log(new Error(ex));”,如此链接 ELMAH - 没有 HttpContext 的异常日志,但这也没有帮助。不知道我还需要做什么。请帮忙。这是 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>

I followed the steps mentioned in this article http://dotnetslackers.com/articles/aspnet/Getting-ELMAH-to-work-with-WCF-services.aspx to configure WCF service to setup error logging by ELMAH. it works with wsHttpBinding with Visual studio webserver, but when I host it in IIS (5/6) and change the binding to basicHttpBinding, it is not logging the errors. I tried to change the error signalling code to "Elmah.ErrorLog.GetDefault(null).Log(new Error(ex));" as mentioned at this link ELMAH - Exception Logging without having HttpContext, but that didn't help either. not sure what else I need to do. Please help. here is the config for the WCF service (I tried commenting and uncommenting the aspnetcompatibility as well, but didn't work). if there is a working sample with basicHttpBinding, that would be very helpful. thanks in advance.

  <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-10-14 18:33:10

我发现它正在发送邮件,但没有将错误记录到数据库中。这可能是数据库的权限问题(即使我可以完全访问我的 Windows 登录 ID 的数据库,并且在 Visual Studio Web 服务器中托管并且使用 wsHttpBinding 时记录正常)。我将其部署到服务器并在应用程序池中配置了不同的帐户,之后它将错误成功记录到数据库,而无需对本文中的代码进行任何更改。我仍然不确定为什么它不将错误从本地 IIS 记录到数据库(我什至尝试在 web.config 中将模拟设置为 true,以便在记录时使用我的 id),但这对我来说不是一个大问题,因为部署后工作正常。谢谢。

I figured out that it is sending mails, but not logging errors to database. it could be permissions issue with database (even though I have full access to the database for my windows login Id and it logs fine when hosted in visual studio webserver and wsHttpBinding is used). I deployed it to the server and configured with a different account in an application pool and after that it is logging errors successfully to the database without having to make any changes to the code from the article. I am still not sure why it doesn't log the errors to database from local IIS (I even tried setting impersonation to true in web.config so that it uses my id when logging), but that's not a big issue for me, since it works fine after deployment. thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文