DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 972914 - Last Review: September 17, 2009 - Revision: 2.0

On This Page

INTRODUCTION

This article describes some examples that you can use to enable logging information for several Windows Workflow Foundation namespaces.

MORE INFORMATION

How to enable workflow logging

You can use the configuration file to create output of Windows Workflow Foundation logging information to help in debugging scenarios. Windows Workflow Foundation uses the configuration format that was introduced in the Microsoft .NET Framework 2.0. The following examples show how to enable logging information for several Windows Workflow Foundation namespaces. To use a configuration file to configure the workflow runtime engine, you first must create a .config file for your application (app.config) or web service (web.config). For example, if you want to enable logging for a Test.exe application process, create a Test.exe.config file.

Example 1

In this example, the first add node enables logging to a file. The file is created in the host application directory by using the name WorkflowTrace.log. In the remaining lines in this example, you can specify the namespaces for which to capture logging information and the amount of information that is traced.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <switches>
        <add name="System.Workflow LogToFile" value="1" />
        <add name="System.Workflow.Runtime" value="All" />
        <add name="System.Workflow.Runtime.Hosting" value="All" />
        <add name="System.Workflow.Runtime.Tracking" value="All" />
        <add name="System.Workflow.Activities" value="All" />
        <add name="System.Workflow.Activities.Rules" value="All" />       
    </switches>
  </system.diagnostics>
</configuration>

Example 2

In this example, you enable logging to a TraceListener by setting the name parameter equal to "System.Workflow LogToTraceListeners". When you set this parameter, Windows Workflow Foundation will enumerate each TraceListener created within the host application and send all logging information to the TraceListener.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <switches>
        <add name="System.Workflow LogToTraceListeners" value="1" />
        <add name="System.Workflow.Runtime" value="All" />
        <add name="System.Workflow.Runtime.Hosting" value="All" />
        <add name="System.Workflow.Runtime.Tracking" value="All" />
        <add name="System.Workflow.Activities" value="All" />
        <add name="System.Workflow.Activities.Rules" value="All" />
    </switches>
  <trace autoflush="true" indentsize="4">
    <listeners>
            <add name="customListener"
             type="System.Diagnostics.TextWriterTraceListener"
             initializeData="WFTrace.log" />
    </listeners>
  </trace>
  </system.diagnostics>
</configuration>

Example 3

In this example, an absolute path is specified in the initializeData attribute. Also, some additional options are specified by using the following traceOutputOptions attributes: ProcessId and DateTime.

If these attributes are being used for a Web application and if multiple instances of W3wp.exe are running, each attribute will create its own trace file. In this scenario, in addition to the WFTrace.log file, you will have files that are named <GUID>WFTrace.log, in which <GUID> is a unique identifier.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.Workflow.Runtime" >
        <listeners>
          <add name = "System.Workflow"/>
        </listeners>
      </source>
      <source name="System.Workflow.Runtime.Hosting">
        <listeners>
          <add name="System.Workflow"/>
        </listeners>
      </source>
      <source name="System.Workflow.Activities">
        <listeners>
          <add name="System.Workflow"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="System.Workflow"
           type="System.Diagnostics.TextWriterTraceListener"
           initializeData="d:\_temp\Log\WFTrace.log"
           traceOutputOptions="DateTime,ProcessId"/>
    </sharedListeners>
    <switches>
      <add name="System.Workflow.LogToTraceListeners" value="1"/>
      <add name="System.Workflow.Runtime" value="All" />
      <add name="System.Workflow.Runtime.Hosting" value="All" />
      <add name="System.Workflow.Runtime.Tracking" value="All" />
      <add name="System.Workflow.Activities" value="All" />
      <add name="System.Workflow.Activities.Rules" value="All" />
    </switches>
  </system.diagnostics>
</configuration>

REFERENCES

For more information about a workflow trace, visit the following MSDN Web site:
http://blogs.msdn.com/madhuponduru/archive/2008/01/17/workflow-trace.aspx (http://blogs.msdn.com/madhuponduru/archive/2008/01/17/workflow-trace.aspx )
For more information about workflow configuration files, visit the following MSDN Web site:
http://msdn.microsoft.com/en-us/library/ms732240.aspx (http://msdn.microsoft.com/en-us/library/ms732240.aspx)

APPLIES TO
  • Windows Workflow Foundation
Keywords: 
kbhowto kbsurveynew KB972914
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support