IIS 500 Error WCF Service and Failed Request Tracing not info

久未见 提交于 2019-12-08 03:30:56

问题


I have a WCF service running in IIS 8.5 on Windows Server 2012 R2 with AppPool Integrated.

I open url in the server: http://localhost:50123/MyService.svc

I have HTTP 500 Internal Server Error. (IExplorer cannot show the page)

I have not found the problem in Event logs, IIS Logs.

I apply this steps: https://peter.hahndorf.eu/blog/iislogging.html

Disable IE “Friendly HTTP error messages”

<customErrors mode=”Off” />

<httpErrors errorMode="Detailed" />

<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>

I use WCF tracing, but not view the error messsage.

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel" propagateActivity="true" switchValue="All">
        <listeners>
          <add name="xmlTraceListener" />
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="All">
        <listeners>
          <add name="xmlTraceListener" />
        </listeners>
      </source>
      <source name="System.Net">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.HttpListener">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.Sockets">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
      <source name="System.Net.Cache">
        <listeners>
          <add name="System.Net" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xmlTraceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Servitelco\Logs\IntegrationLabor\ServiceWcf.svclog" />
      <add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Servitelco\Logs\IntegrationLabor\SystemNet.trace.log" traceOutputOptions="DateTime" />
    </sharedListeners>
    <switches>
      <add name="System.Net" value="Verbose" />
      <add name="System.Net.Sockets" value="Verbose" />
      <add name="System.Net.Cache" value="Verbose" />
      <add name="System.Net.HttpListener" value="Verbose" />
    </switches>
  </system.diagnostics>


 <system.serviceModel>

        <diagnostics>
            <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxSizeOfMessageToLog="26214445" />
        </diagnostics>

I setup "Failed Request Tracing", for All content, verbose error logging, HTTP errors in range 400-600.

I open fr000001.xml file from %systemdrive%\inetpub\logs\FailedReqLogFiles\W3SVC1

I only view MODULE_SET_RESPONSE_ERROR_STATUS Warning:

ModuleName ManagedPipelineHandler
Notification 128
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0 ErrorCode 0
ConfigExceptionInfo
Notification EXECUTE_REQUEST_HANDLER
ErrorCode The operation completed successfully. (0x0)

Error 500:

HttpStatus 500
HttpReason Internal Server Error

and successfully ?

ErrorCode The operation completed successfully. (0x0)

Not more info about the error.

About the error:

I have and WCF Inspector with IDispatchMessageInspector

Like https://patrickdesjardins.com/blog/wcf-inspector-for-logging

The error is about attribute logFileName="c:\log.txt"

If the path exists, all is OK. If the path NOT exists, I get Http 500 Error.

 <extensions>
            <behaviorExtensions>
                <add name="myLogBehavior"
                     type="MyServiceA.LogFileBehaviorExtensionElement, MyServiceA" />
            </behaviorExtensions>
        </extensions>


  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <MyLogFileBehavior logFileName="C:\Servitelco\Logsxxx\IntegrationLabor\log.txt" />
    </behavior>
  </serviceBehaviors>

<endpointBehaviors>
          <behavior name="behavior1">
              <myLogBehavior logFileName="c:\log.txt" />
          </behavior>
      </endpointBehaviors>

This means there is an unhanded exception with in the code.

Event viewer, IIS Logs, WCF tracing, Failed Request Tracing not shown the error message, why? How get the full error message ? OS not logging the error in anyway ?


回答1:


I had the same problem - 500 error returned to client, no event log error, no custom errors logged from Global.asax, Failed Request Tracing showed MODULE_SET_RESPONSE_ERROR_STATUS Warning for ManagedPipelineHandler.

Solved by adding a Try/Catch at the very highest level of my controller...

    <HttpPost>
    Public Function Main() As IHttpActionResult
    Try
       ... all logic here...
       Return ResponseMessage(New HttpResponseMessage(HttpStatusCode.OK))
    Catch Ex As Exception
       Errorcl.HandleException(err) 'internal logging of error
       Return ResponseMessage(New HttpResponseMessage(HttpStatusCode.InternalServerError))
    End Try


来源:https://stackoverflow.com/questions/51229490/iis-500-error-wcf-service-and-failed-request-tracing-not-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!