web analytics

Using Service Trace Viewer to Diagnose WCF Service

Options

codeling 1602 - 6666
@2016-03-04 08:51:27

Windows Communication Foundation (WCF) Service Trace Viewer Tool (SvcTraceViewer.exe) helps you analyze diagnostic traces that are generated by WCF. Service Trace Viewer provides a way to easily merge, view, and filter trace messages in the log so that you can diagnose, repair, and verify WCF service issues.

 

@2016-03-04 08:53:53

Configuring Tracing

Diagnostic traces provide you with information that shows what is happening throughout your application's operation. As the name implies, you can follow operations from their source to destination and through intermediate points as well.

You can configure tracing using the application’s configuration file—either Web.config for Web-hosted applications, or Appname.config for self-hosted applications. The following is an example:

 

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
            <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="sdt"
                   type="System.Diagnostics.XmlWriterTraceListener"
                   initializeData= "c:\logs\MyWCFExample.svclog" />
            </listeners>
         </source>
    </sources>
</system.diagnostics>

 

In this example, the name and type of the trace listener is specified. The Listener is named sdt and the standard .NET Framework trace listener (System.Diagnostics.XmlWriterTraceListener) is added as the type. The initializeData attribute is used to set the name of the log file for that Listener to be MyWCFExample.svclog. For the log file, you can substitute a fully-qualified path for a simple file name.

The tracing level is controlled by the switchValue setting. The available tracing levels are described in the following table.

Trace Level

Description

Critical

  • Logs Fail-Fast and Event Log entries, and trace correlation information. The following are some examples of when you might use the Critical level:

  • Your AppDomain went down because of an unhandled exception.

  • Your application fails to start.

  • The message that caused the failure originated from the process MyApp.exe.

Error

  • Logs all exceptions. You can use the Error level in the following situations:

  • Your code crashed because of an Invalid Cast Exception.

  • A "failed to create endpoint" exception is causing your application to fail on startup.

Warning

  • A condition exists that may subsequently result in an error or critical failure. You can use this level in the following situations:

  • The application is receiving more requests than its throttling settings allow.

  • The receiving queue is at 98 percent of its configured capacity.

Information

  • Messages helpful for monitoring and diagnosing system status, measuring performance, or profiling are generated. You can utilize such information for capacity planning and performance management. You can use this level in the following situations:

  • A failure occurred after the message reached the AppDomain and was deserialized.

  • A failure occurred while the HTTP binding was being created.

Verbose

  • Debug-level tracing for both user code and servicing. Set this level when:

  • You are not sure which method in your code was called when the failure occurred.

  • You have an incorrect endpoint configured and the service failed to start because the entry in the reservation store is locked.

ActivityTracing

Flow events between processing activities and components.

This level allows administrators and developers to correlate applications in the same application domain.

  • Traces for activity boundaries: start/stop.

  • Traces for transfers.

You can use add to specify the name and type of the trace listener you want to use. In the example configuration, the Listener is named sdt and the standard .NET Framework trace listener (System.Diagnostics.XmlWriterTraceListener) is added as the type. Use initializeData to set the name of the log file for that Listener. In addition, you can substitute a fully-qualified path for a simple file name.

@2021-01-13 15:11:29

You can find Service Trace Viewer executable SvcTraceViewer.exe by navigating to your WCF installation location (C:\Program Files\Microsoft SDKs\Windows\vxx.x\Bin\NETFX x.x.x Tools, or C:\Program Files(x86)\Microsoft SDKs\Windows\vxx.x\Bin\NETFX x.x.x Tools).

@2021-01-13 15:23:47

WCF tracing is built on top of System.Diagnostics. To use tracing, you should define trace sources in the configuration file or in code. WCF defines a trace source for each WCF assembly. The System.ServiceModel trace source is the most general WCF trace source, and records processing milestones across the WCF communication stack, from entering/leaving transport to entering/leaving user code. The System.ServiceModel.MessageLogging trace source records all messages that flow through the system.

Tracing is not enabled by default. To activate tracing, you must create a trace listener and set a trace level other than "Off" for the selected trace source in configuration; otherwise, WCF does not generate any traces. If you do not specify a listener, tracing is automatically disabled. If a listener is defined, but no level is specified, the level is set to "Off" by default, which means that no trace is emitted.

You can configure tracing by editing the application's configuration file—either Web.config for Web-hosted applications, or Appname.exe.config for self-hosted applications. The following is an example of such edit. For more information on these settings, see the "Configuring Trace Listeners to Consume Traces" section.

<configuration> 
   <system.diagnostics> 
      <trace autoflush="true" />

      <sources> 
         <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing" 
                    propagateActivity="true"> 
            <listeners> 
               <add name="traceListener"
                   type="System.Diagnostics.XmlWriterTraceListener"
                   initializeData= "c:\log\Traces.svclog" /> 
            </listeners> 
         </source> 
      </sources> 
   </system.diagnostics> 
</configuration> 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com