I want to save trace information in .svclog files, but only for failed requests. Is it possible? If so, how exactly?
I have a WCF service calling hundreds of times per minute. In rare cases, clients will receive a 500 error message that occurs outside of my code running inside WCF (usually security issues). I would like to know exactly why these errors occur and what causes them.
I would also really like to use the Trace Viewer tool to view .svclog files.
As far as I can tell, I have two options: 1) trace the FERB tool by registering failed requests using the system.webServer \ tracing parameters. Unfortunately, I really don't like the IE tracer interface, and I don't get enough information from the trace logs to find out why the error occurred outside of my code.
2) enable global tracing in the system.diagnostics \ trace section. This section creates great trace logs with everything I could ever want. However, I cannot find a way to only capture information for failed requests. This section displays trace information for ALL requests. My trace logs fill up quickly!
My 500 errors are intermittent and rare. Ultimately, I want my .svclog trace to turn on, but only when it fires, when failed requests occur.
Please advice, if possible?
Thanks!
Edit:
Graham, I followed your advice, and I do not see the magazines that I expect. Here are the relevant sections from web.config:
<system.diagnostics> <trace> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <filter type="" /> </add> </listeners> </trace> <sources> <source name="System.ServiceModel" switchValue="Error"> <listeners> <add name="wcfTracing" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces1.svclog"/> <add name="log4netTracing" type="AzureWatch.Model.Service.Log4netTraceListener,AzureWatch.Model.Service"/> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Error"> <listeners> <add name="wcfTracing" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces2.svclog"/> </listeners> </source> </sources> </system.diagnostics> <diagnostics wmiProviderEnabled="true"> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxSizeOfMessageToLog="1000000" maxMessagesToLog="-1" /> </diagnostics>
Here is the WCF client error:
<Exception> <Type>System.Net.Sockets.SocketException</Type> <Message>An existing connection was forcibly closed by the remote host</Message> <StackTrace> <Frame>at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</Frame> </StackTrace> </Exception>
Unfortunately, there is not a single file that is registered by one of the tracers. The failed request log contains the following:
-GENERAL_READ_ENTITY_END BytesReceived 0 ErrorCode 2147943395 ErrorCode The I/O operation has been aborted because of either a thread exit or an application request. (0x800703e3) Warning -MODULE_SET_RESPONSE_ERROR_STATUS ModuleName ManagedPipelineHandler Notification 128 HttpStatus 400 HttpReason Bad Request HttpSubStatus 0 ErrorCode 0 ConfigExceptionInfo Notification EXECUTE_REQUEST_HANDLER ErrorCode The operation completed successfully. (0x0) 0 msInformational