ELMAH的错误日志记录不能在IIS中使用basicHttpBinding托管在WCF服务中 [英] error logging by ELMAH not working in WCF service hosted in IIS with basicHttpBinding

查看:124
本文介绍了ELMAH的错误日志记录不能在IIS中使用basicHttpBinding托管在WCF服务中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照本文中提到的步骤 http://dotnetslackers.com/articles/aspnet/Getting-ELMAH-to-work-with-WCF-services.aspx 配置WCF服务以设置ELMAH的错误记录。它与Visual Studio Webserver的wsHttpBinding一起工作,但是当我在IIS(5/6)中托管它并将绑定更改为basicHttpBinding时,它不会记录错误。我尝试将错误信号代码更改为 Elmah.ErrorLog.GetDefault(null).Log(new Error(ex)); ,如本链接所述 ELMAH - 没有HttpContext的异常记录,但是没有帮助。不知道我还需要做什么。请帮忙。这是WCF服务的配置(我尝试评论和取消注释aspnetcompatibility,但没有工作)。如果有一个工作样本与basicHttpBinding,那将是非常有益的。感谢提前。

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>


推荐答案

我发现它正在发送邮件,将错误记录到数据库。它可能是数据库的权限问题(尽管我可以完全访问我的Windows登录ID的数据库,并且当在visual studio webserver中托管并且使用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.

这篇关于ELMAH的错误日志记录不能在IIS中使用basicHttpBinding托管在WCF服务中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆