Service Trace Viewer

Windows Communication Foundation (WCF) Service Trace Viewer helps you analyze activity tracing (*.svclog) diagnostic traces that are generated by WCF listeners. Service Trace Viewer provides a way to easily merge, view, and filter trace messages so that you can diagnose, repair, and verify WCF service issues.

See Service Trace Viewer Resources for additional information about tracing functionalities provided by WCF.

Send comments about this topic to Microsoft.


Using Service Trace Viewer

This section includes information about using Service Trace Viewer to view and analyze trace data generated by Windows Communication Foundation (WCF).

Configuring Tracing

To configure tracing for WCF messages, use Service Configuration Editor (SvcConfigEditor.exe). For more information about configuring tracing, see Service Configuration Editor Help.

In This Section

Open Trace Files

Enables you to open any supported trace file, add and integrate additional trace files, or open and merge a group of trace files simultaneously.
View Trace Data

Provides four different views: Activity view, Project view, Message view and Graph view.
Filter Traces

Makes the analysis of trace files easier.
Find Trace Data

Describes how you can locate trace data that you want.
Navigate Trace Data

Provides various ways to navigate in traces.


Open Trace Files

The Service Trace Viewer supports three file types:

  • Windows Communication Foundation (WCF) Tracing File (.svclog)

  • Event Tracing File (.etl)

  • Crimson Tracing File

Opening Trace Data

Service Trace Viewer enables you to open any supported trace file, add and integrate additional trace files, or open and merge a group of trace files simultaneously.

To open a trace file

  1. Start Service Trace Viewer by using a command window to navigate to your WCF installation location and then type SvcTraceViewer.exe.
Note:
TraceViewer can associate with two file types: .svclog and .stvproj. You can use two parameters in command line to register and unregister the file extensions.

/register: register the association of file extensions ".svclog" and ".stvproj" with SvcTraceViewer.exe

/unregister: unregister the association of file extensions ".svclog" and ".stvproj" with SvcTraceViewer.exe

  1. When Service Trace Viewer starts, click File and then point to Open. Navigate to the location where your trace files are stored.

  2. Double-click the trace file that you want to open. You can also press SHIFT while clicking multiple trace files to select and open them simultaneously. Service Trace Viewer merges the content of all files and presents one view. For example, you can open trace files of both client and service. This is useful when you have enabled message logging and activity propagation in configuration. In this way, you can examine the message exchange between client and service. You can also drag multiple files into the viewer, or use the Project tab. See the Managing Project section for more details.

  3. To add additional trace files to the collection that is open, click File and then point to Add. In the window that opens, navigate to the location of the trace files and double-click the file you want to add.

Event Tracing and Crimson Tracing

The viewer’s native format is the activity tracing format WCF emits. Traces emitted in a different format must be converted before the viewer displays them. Currently, in addition to the activity tracing format, the viewer supports event tracing and crimson tracing.

When you open a file that does not contain activity traces, the viewer attempts to convert the file. You must specify the name and location of the file that will contain the converted trace data. Once the data has been converted, the viewer displays the content of the new file.

Note:
Conversion requires disk space to store the converted trace data. Make sure you have enough disk space available to store the data before you start a conversion. Otherwise, the conversion fails.

Managing Projects

The viewer supports projects to facilitate viewing multiple trace files. For example, if you have a client trace file and a service trace file, you can add them to a project. Then, every time you open the project, all the trace files in the project are loaded simultaneously.

There are two ways to manage projects.

  • In the File menu, you can open, save and close projects.

  • In the Project tab, you can add files to a project.

Loading Large Trace Files

Trace files can be very large. For example, if you enable tracing on the “Verbose” level, the resulting trace file for running a few minutes can easily be hundreds of megabytes or even larger, depending on network speed and communication pattern.

When you open a very large trace file in the Service Trace Viewer, system performance can be negatively impacted. The loading speed and the response time after loading can be slow. Actual speed differs from time to time, depending on your hardware configuration. In most PCs, loading a trace file larger than 200M has a severe performance impact. For traces files larger than 1G, the tool may use up all available memory, or stop responding for a very long time.

To avoid the slow loading and response time in analyzing large trace files, the Service Trace Viewer provides a feature called Partial Loading, which only loads a small part of the trace at a time. For example, you may have a trace file over 1GB, running for several days on the server. When some errors have occurred and you want to analyze the trace, you do not need to open the entire trace file. Instead, you can load the traces within a certain period of time when the error might have occurred. As the scope is smaller, Trace Viewer can load the file faster, and you can identify the errors using a smaller set of data.

Enabling Partial Loading

You do not need to manually enable partial loading. If the total size of the trace file(s) you attempt to load exceeds 40MB, Service Trace Viewer automatically displays a Partial Loading dialog for you to select the part that you want to load.

Note:
Because traces may not be distributed evenly in the time span, the length of the time period you specify in the Partial Loading toolbar may not be proportional to the loading size shown. The actual loading size can be smaller than the Estimated Size in the partial loading dialog.

Adjusting Partial Loading

After you have partially loaded the trace file, you may want to change the data set being loaded. You can do so by adjusting the Partial Loading toolbar at the top of the viewer:

  1. Move the toolbar by mouse, or input the Begin and End time.

  2. Click the Adjust button.


View Trace Data

Windows Communication Foundation (WCF) emits traces using the activity tracing format. In the activity tracing model, individual traces are grouped in activities according to their purpose. Logical control flow is transferred between activities. For example, during the lifetime activity of an application, many "message send activities" appear and disappear.

At runtime, WCF creates a set of activities that describes what is happening in the system.

Switching to Different Views

The Service Trace Viewer provides the following four different views. They are displayed as tabs on the left pane of the Viewer, and can also be accessed from the View menu.

  • Activity view

  • Project view

  • Message view

  • Graph view

Activity view

Once the trace files are imported, you can see the contents of the files grouped into activities and displayed in the Activity window in the left-hand pane.

The window displays activity names, number of traces in the activity, duration time, and the start and end time.

By clicking any of the listed activities, the traces in this activity are displayed in the trace pane on the right. You can then select a trace to view its details.

You can select multiple activities by pressing the Ctrl or Shift key and clicking the desired activities. The trace pane displays all the traces of the selected activities.

You can double-click an activity to display it in Graph view. The alternative way is to select an activity and switch to Graph view.

Note:
The activity “000000000000” is a special activity that cannot be displayed in the Graph view. Because all other activities are linked to it, displaying this activity has a severe performance impact.

You can click the column title to sort the activity list. Activities that contain warning traces have a yellow background, and those that contain exception traces have a red background.

There are different types of activities, and each type corresponds to an icon on the left side of each activity. Refer to the Understanding Trace Icons section for their meaning.

Project view

This view enables you to manage trace files in the current project. See the Managing Project section for more details.

Graph view

One of the most powerful features of Service Trace Viewer is the Graph view, which displays the trace data for a given activity in chart form. The chart form enables you to see the stepwise execution of events and the interrelationships between multiple trace files as data moves between them.

To switch to Graph view, select an activity in the Activity view and click the Activity tab, or a message log trace in the Message view. If multiple trace files are loaded and the activity involves traces from more than one file, all of the relevant traces appear in the Graph view. Double-clicking the activities and message log traces also lead you to the Graph view.

In Graph view, each vertical column represents an activity and each block in the column represents a trace. The activities are grouped by process (or thread). The small arrows between activities represent transfers. The big arrows between processes represent message exchange. The activity in selection is always in yellow.

Selecting traces in the graph

  1. Click a block in the graph.

  2. Use the up and down key to select its neighboring traces.

  3. Observe the trace information in the Trace Pane and Detail Pane.

Expanding or Collapsing Activity Transfers

You can expand activity transfers when the activity in selection transfers out to another activity. It enables you to follow the transfers. This feature is similar to the Follow Transfer in the Activity menu (see the Navigating section).

To expand or collapse activity transfers

  1. Locate the transfer trace with a “+” sign on the left of the transfer icon.

  2. Click the “+”, or press Ctrl and “+” using the keyboard.

  3. The next activity appears in the graph.

  4. A “-“ appears on the left of the transfer icon. Click the “-“ sign or press CTRL and “-“, the activity transfer collapses.

Note When an activity has multiple transfers into it and you expand one of the transfers, activities that lead up to the new activity from the root are displayed. These new activities appear in collapsed form. If you want to see the details of these activities, expand them vertically by clicking the expand icon in the header of the graph.

Expanding or Collapsing Activities Vertically

The Viewer hides unnecessary detail in the activity graph by collapsing activities. In a collapsed activity, individual traces are not displayed. Only important trace transfers appear. If you want to view all traces in an activity, expand the activity vertically by clicking the expand symbol of the activity in the header of the graph:

To expand or collapse activities vertically

  1. Click the “-“ icon in the activity header to collapse the activity vertically.

  2. Notice that only important transfers, message logs, warning and exception traces are shown in the activity.

  3. Click the “+” icon in the activity header to expand the activity vertically.

  4. Notice that all traces are displayed in the graph.

Options

You can select two options from the Option menu in Graph view.

  • Show Activity Boundary Traces, which when unchecked, ignore the activity boundary traces in the graph.

  • Show non-message Verbose Traces, which when unchecked, ignore verbose level traces, except for message traces. In most cases, verbose level traces are less important for analysis. This option is helpful when you do not want to analyze verbose level traces and only want to focus on more important traces.

Layout Mode

The Viewer has two layout modes: Process and Thread. This setting defines the largest unit of organization. The default layout mode is Process, which means that activities are grouped by processes in the graph.

Execution List

You can select which process or thread to be displayed in the graph from this drop-down list. For example, if you have the trace files of two clients (A and B) and one service opened, and you only want to display the service and client A in the graph, you can deselect client B from the list.

Viewing Trace Details

To view a trace detail, select a trace in the Tracing pane. The details are displayed in the Detail pane.

You can also review the TraceViewer Tool topic, which lists all the icons used in the Trace Viewer Tool and their corresponding meanings.

Tracing Pane

The upper right pane in the view is the Tracing Pane. It lists all the traces in the selected activity with extra information such as description, trace level, thread ID, process name, and other information.

You can copy the raw XML of the trace to the clipboard by right-clicking a trace and selecting Copy Trace to Clipboard.

Detail Pane

The bottom right pane in the view is the Detail Pane. It provides three tabs to view trace details.

The Formatted view displays the information in a more organized way. It lists all known XML elements in tables and trees, making it easier to read and understand the information.

The XML view displays XML corresponding to the selected trace. It supports highlighting and syntax color. When you use Find to search strings, it highlights the search results.

The Message view displays the message part of the XML in message log traces. It is invisible when you select a non-message trace.


Filter Traces

To make the analysis of trace files easier, you can filter them in three different ways.

  • The filter toolbar provides access to pre-defined filters. It is accessible through the View menu.

  • The built in filter of the viewer can be used to selectively filter parts of the WCF infrastructure traces. By default, it is set to allow all infrastructure messages to pass through. The settings of this filter are defined in the Filter Options sub-menu under the View menu.

  • Custom XPath filters give users full control over filtering. They can be defined in the Custom Filter menu.

Only trace data that passes through all active filters is displayed.

Using the Filter Toolbar

The filter toolbar appears across the top of the tool. If it is not present, you can activate it in the View menu. The bar has three components:

  • Look for: Look for defines the subject to look for in the filter operation. For example, if you want to find all traces that were emitted in the context of process X, set this field to X and the Search In field to ‘Process Name’. This field changes to a DateTime selector control when a time based filter is selected.

  • Search in: This field defines the type of filter to apply. Valid values include ‘Process Name’, ‘Time Range’, ‘Event ID’, and ‘endpoint address’.

  • Level: The level setting defines the minimum trace level allowed by the filter. For example, the ‘Error and Up’ only the traces at the Error and Critical level are displayed. This filter combines with the criteria specified by Look For and Search In.

The Filter Now button starts the filter operation. Some filters, especially when they are applied to a large data set, take a long time to complete. You can cancel the filter operation by pressing the Stop button that appears in place of the Filter Now button when the filter operation has been started.

The Clear button resets all filters to allow all traces to pass through.

Filter Options

The viewer can automatically remove WCF traces from the view. It can selectively remove traces emitted by specific areas of WCF, for example, removing transaction related traces from the view.

The settings of this filter are defined in the Filter Options sub-menu under View menu.

Custom Filters

If you are familiar with the XML Path Language (XPath), you can use it to construct your own custom filters to search the trace data for any XML element of interest. The filters are accessible through the filter toolbar.

Custom filters can include parameters. You can also import pre-existing custom XPath filters.

Creating a custom filter

Filters can be created in two ways:

Creating a Custom Filter using the Template Wizard

You can click an existing trace and create a filter based on the structure of the trace. This example creates a custom filter based on thread ID.

  1. In the trace pane in the top right area of the viewer, select a trace that includes the element you want to filter for.

  2. Click the Create Custom Filter button located at the top of the trace pane.

  3. In the dialog box that appears, enter a name for your filter. In this example, enter ‘Thread ID’. You can also provide a description of your filter.

  4. The tree view on the left displays the schema of the trace record you selected in step 1. Browse to the element you want to create a condition for. In this example, browse to the ThreadID most likely to be located in the System.Execution node. Double-click the ThreadID attribute in the tree view. This creates an expression for the attribute on the right of the dialog.

  5. Change the parameter field for the ThreadID condition from None to ‘{0}’. This step enables the ThreadID value to be configured when the filter is applied. (See the How to Apply a Filter section) You can define up to four parameters. Conditions are combined using the OR operator.

  6. Click Ok to create the filter.

Note Once a filter has been created using the template wizard, it can only be edited manually. It is not possible to activate the wizard for a filter that has been created previously. In addition, the conditions of an XPath filter created in the template wizard are combined using the OR operator. If you require an AND operation, you can edit the filter expression after it has been created.

Creating a Custom Filter Manually

To create a custom XPath filter manually

  1. In the View menu, click the Custom Filters menu item.

  2. In the dialog that appears, click New.

  3. At the minimum, specify a Filter Name and XPath expression.

  4. Click OK.

Applying a Custom Filter

To apply a custom filter

  1. Select the filter you want to apply in the Search In field of the filter toolbar. For the previous example, select ‘Thread ID’.

  2. Specify the value you are looking for in the Find What field. In our example, enter the ID of the thread you want to search for.

  3. Click Filter Now, and observe the result of the operation.

If your filter uses multiple parameters, enter them using ‘;’ as a separator in the Find What field. For example, the following string defines 3 parameters: ‘1;findValue;text’. The viewer applies ‘1’ to the {0} parameter of the filter. ‘findValue’ and ‘text’ are applied to {1} and {2} respectively.

Sharing Custom Filters

Custom filters can be shared between locations where the Trace Viewer tool is run. You can export the filters in one instance to a definition file, and import this file at another location.

To import a custom filter

  1. In the View menu, click Custom Filters.

  2. In the dialog box that opens, click the Import button.

  3. Navigate to the custom filter file (.stvcf), click the file, and click the Open button.
To export a custom filter

  1. In the View menu, click Custom Filters.

  2. In the dialog box that opens, select the filter you want to export.

  3. Click the Export button.

  4. Specify the name and location of the custom filter definition file (.stvcf), and click the Save button.
Note:
These custom filters can only be imported and exported from Service Trace Viewer. They cannot be read by other tools.


Find Trace Data

This section describes how you can locate trace data that you want.

Finding Trace Data

The viewer provides two different ways to find data:

  • The Find toolbar provides a quick access to the most common find options.

  • The Find dialog provides more find options. It is accessible through the Edit menu, or by the short key Ctrl + F.

The Find toolbar appears at the top of the viewer. If it is not present, you can activate it in the View menu. The toolbar has two components:

  • Find What: Allows you to enter a search keyword.

  • Look In: Allows you to enter the search scope. You can select whether to search in all activities or in the current activity only.

The find dialog provides two additional options:

  • Find target: The “Raw log data” option searches the keyword in all raw data. The “XML Text” and “XML Attribute” options only search in XML elements. The “Logged Message” option searches the keyword only in messages.

  • Ignore root activity: The search ignores the traces in the “000000000000” activity. This improves performance in large trace files when the root activity has thousands of traces, most of which are transfers.


Navigate Trace Data

Because traces are recorded step by step during application runtime, navigating traces can help you to debug your application. The Service Trace Viewer provides various ways to navigate in traces.

Step Forward or Backward

If you consider each trace as a line of code in the program, stepping forward is very similar to “Step over” in the Visual Studio Integrated Development Environment (IDE). The difference is that you can also step backward in the traces. Stepping forward means moving to the next trace in the activity.

  • Step Forward: Use the Activity menu, or press “F10”. You can also use arrow key “down” in the trace pane.

  • Step Backward: Use the Activity menu, or press “F9”. You can also use arrow key “up” in the trace pane.

Follow Transfer

Transfer traces are special traces in the trace file. An activity may transfer to another activity by a transfer trace. For example, “Activity A” may transfer to “Activity B”. In this case, there is a transfer trace in the “Activity A” with the name “To: Activity” and the transfer icon. This transfer trace is a link between the two traces. In “Activity B”, there might also be a transfer trace at the end of the activity to transfer back to “Activity A”. This is similar to function calls in programs: Activity A calls Activity B, then Activity B returns.

“Follow transfer” is similar to “Step into” in a debugger. It follows the transfer from Activity A to Activity B. It does not have any effect on other traces.

There are two ways to follow a transfer: by mouse or by keyboard.

  • By Mouse: Double-click the transfer trace in the trace pane.

  • By Keyboard: Select a transfer trace, and use “Follow Transfer” in the Activity menu, or press “F11”.

Note:
In many cases, when Activity A transfers to Activity B, Activity A waits until Activity B transfers back to Activity A. This means that Activity A has no trace logged during the period when Activity B is actively tracing. However, it is also possible that Activity A does not wait, and continues to log traces. It is also possible that Activity B does not transfer back to Activity A. Therefore, activity transfers are still different from function calls in this sense. You can understand activity transfers better in Graph view.

Jump to Next or Previous Transfer

When you are analyzing the current activity, you may want to quickly find the activities it transfers to. “Jump to next transfer” allows you to locate the next transfer trace in the activity. Once you find the transfer trace, you can use “Follow transfer” to step into the next activity:

  • Jump to Next Transfer: Use the Activity menu, or press “Ctrl + F10”.

  • Jump to Previous Transfer: Use the Activity menu, or press “Ctrl + F9”.

Navigate in Graph View

Although navigating in the activity pane and trace pane is similar to debugging, using the Graph view provides a much better experience in navigation. See View Trace Data for more information.


Service Trace Viewer Resources

For more information about Windows Communication Foundation (WCF) Tracing, see the following resources:

  • Windows Communication Foundation on the MSDN Web site.

  • WCF Activity Tracing Model, which describes Activity Tracing.

  • TraceViewer Tool, which lists all the icons used in the Trace Viewer Tool. and their corresponding meanings.

  • Tracing, which contains a collection of conceptual topics on WCF Tracing.

  • Introduction to Building Windows Communication Foundation Services at the MSDN Library.

  • Class Library documentation for the .NET System.Diagnostics namespace at the MSDN Library.

  • Windows Communication Foundation technical forum.