Partilhar via


How to: Configure Tracking with WorkflowServiceHost

This topic applies to Windows Workflow Foundation 4 (WF4).

This topic explains how to configure tracking for a .NET Framework version 4 workflow hosted in WorkflowServiceHost. It is configured through a Web.config file by specifying a service behavior.

Configure Tracking in Configuration

  1. Add the EtwTrackingParticipant using the <behavior> element in a configuration file, as shown in the following example.

    <behaviors>
       <serviceBehaviors>
         <behavior>
           <etwTracking profileName="Sample Tracking Profile" />
         </behavior>            
       </serviceBehaviors>
    <behaviors>
    

    Note

    The preceding configuration sample is using simplified configuration. For more information, see Simplified Configuration.

    The preceding configuration sample adds a EtwTrackingParticipant and specifies a tracking profile name. Tracking profiles are created in a <trackingProfile> element within a <tracking> element. The tracking profile contains tracking queries that permit a tracking participant to subscribe to workflow events that are emitted when the state of a workflow instance changes at runtime. The following example shows how to create a tracking profile.

    <system.serviceModel>
        <tracking> 
         <trackingProfile name="Sample Tracking Profile">
            <workflow activityDefinitionId="*">
               <workflowInstanceQueries>
                 <workflowInstanceQuery>
                    <states>
                       <state name="Started"/>
                       <state name="Completed"/>
                    </states>
                </workflowInstanceQuery>
             </workflowInstanceQueries>
           </workflow>
         </trackingProfile> 
       </tracking>
    </system.serviceModel>  
    

    For more information about tracking profiles, see Tracking Profiles.

    For more information about tracking in general, see Workflow Tracking and Tracing.

Configure Tracking in Code

  1. Add the EtwTrackingParticipant using the EtwTrackingBehavior behavior in code, as shown in the following example.

    host.Description.Behaviors.Add(new EtwTrackingBehavior { ProfileName = "Sample Tracking Profile" });
    

    The preceding code sample adds a EtwTrackingParticipant and specifies a tracking profile name. Tracking profiles are created in a <trackingProfile> element within a <tracking> element as shown in the previous section.

    For more information about tracking profiles, see Tracking Profiles.

    For more information about tracking in general, see Workflow Tracking and Tracing. For an example of configuring tracking programmatically see Configuring Tracking for a Workflow.

See Also

Concepts

Tracking Profiles

Other Resources

Simplified Configuration
Simplified Configuration for WCF Services
Workflow Services