问题描述
我有一个在Windows Server 2012 R2上运行IIS 8.5且集成了AppPool的WCF服务.
I have a WCF service running in IIS 8.5 on Windows Server 2012 R2 with AppPool Integrated.
我在服务器中打开url: http://localhost:50123/MyService.svc
I open url in the server: http://localhost:50123/MyService.svc
我有 HTTP 500内部服务器错误. (IExplorer无法显示该页面)
I have HTTP 500 Internal Server Error. (IExplorer cannot show the page)
我没有在事件日志IIS日志中找到问题.
I have not found the problem in Event logs, IIS Logs.
我执行以下步骤: 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"/>
我使用WCF跟踪,但未查看错误消息.
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>
我为所有内容,详细的错误日志记录,400-600范围内的HTTP错误设置了"失败的请求跟踪".
I setup "Failed Request Tracing", for All content, verbose error logging, HTTP errors in range 400-600.
我从%systemdrive%\ inetpub \ logs \ FailedReqLogFiles \ W3SVC1
我仅查看 MODULE_SET_RESPONSE_ERROR_STATUS警告:
错误500:
并成功?
没有有关该错误的更多信息.
关于错误:
我有IDispatchMessageInspector和WCF检查器
I have and WCF Inspector with IDispatchMessageInspector
就像 https://patrickdesjardins.com/blog/wcf-inspector-for-记录
错误与属性logFileName="c:\log.txt"
如果路径存在,则一切正常.如果该路径不存在,则会出现Http 500错误.
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.
事件查看器,IIS日志,WCF跟踪,失败的请求跟踪未显示错误消息,为什么?如何获取完整的错误消息?操作系统无论如何都不会记录错误?
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 ?
推荐答案
我遇到了同样的问题-500错误返回给客户端,没有事件日志错误,没有从Global.asax记录自定义错误,失败的请求跟踪显示MODULE_SET_RESPONSE_ERROR_STATUS警告ManagedPipelineHandler.
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
这篇关于IIS 500错误WCF服务和失败的请求跟踪失败信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!