Udostępnij za pośrednictwem


Debugging WCF - Traces and Message Logs

There has been enough posts on this topic. But this topic cannot be over emphasized. The best way to debug any WCF issue is to get a complete Message log and trace. We write tons of information to the trace that there is very little (if any) issues that traces cannot solve. Below is a config to generate Message logs and Traces in the Verbose level. The config will create a file e2eTraceTest.e2e in the directory where the config lives.

 <configuration>
          <system.serviceModel>
                  <diagnostics>
                          <messageLogging maxMessagesToLog="30000" 
                                  logEntireMessage="true" 
                                  logMessagesAtServiceLevel="true" 
                                  logMalformedMessages="true" 
                                  logMessagesAtTransportLevel="true">
                          </messageLogging>
                  </diagnostics>
          </system.serviceModel>
          <system.diagnostics>
                  <sources>
                          <source name="System.ServiceModel" 
                                  switchValue="Verbose, ActivityTracing" 
                                  propagateActivity="true" >
                                  <listeners>
                                          <add name="xml" />
                                  </listeners>
                          </source>
                          <source name="System.ServiceModel.MessageLogging" 
                                  switchValue="Verbose">
                                  <listeners>
                                          <add name="xml" />
                                  </listeners>
                          </source>
                  </sources>
                  <sharedListeners>
                          <add name="xml" 
                               type="System.Diagnostics.XmlWriterTraceListener" 
                               initializeData="e2eTraceTest.e2e" />
                  </sharedListeners>
                  <trace autoflush="true" />
          </system.diagnostics>
  </configuration>

Comments