Tracking and Logging
Windows Workflow Foundation provides a tracking infrastructure to track execution of a workflow instance and log the results to files, databases, etc. The tracking runtime implements a workflow instance to emit events related to the workflow lifecycle, events from workflow activities and custom tracking events.
objects are sent to TrackingParticipants
-- The workflow publishes TrackingRecords to which the TrackingParticipants subscribe. TrackingParticipants are registered as extensions to the workflow.
Different types of TrackingRecords:
- ActivityScheduledRecord - Represents a tracking record of an activity being scheduled for execution.
- ActivityStateRecord - Represents a tracking record that is created when an activity changes state.
- BookmarkResumptionRecord - Contains the data sent to a tracking participant by the run-time tracking infrastructure when a Bookmark is resumed.
- CancelRequestedRecord - Represents the data sent by the workflow runtime to tracking participants when CancelChild() or CancelChildren() is called.
- CustomTrackingRecord - Contains the data sent to a tracking participant by the run-time tracking infrastructure when a custom tracking record is raised. Custom TrackingRecords can be derived from this class.
- FaultPropagationRecord - Contains the data sent to a tracking participant by the run-time tracking infrastructure when a fault is propagated from a workflow activity.
- WorkflowInstanceRecord - Contains the data sent to a tracking service by the run-time tracking infrastructure when a workflow instance changes state.
The only built-in TrackingParticipant is
- EtwTrackingParticipant - A consumer of workflow tracking data that emits an
"ETW is an efficient kernel-level tracing facility that lets you log kernel or application-defined events to a log file. You can consume the events in real time or from a log file and use them to debug an application or to determine where performance issues are occurring in the application. ... ETW lets you enable or disable event tracing dynamically thus making it possible to perform detailed tracing in a production environment without requiring computer or application restarts."
==> The standard Windows Event Viewer can thus be used to view the log files.
ETW Tracking Sample from MSDN
TrackingParticipants are configured using TrackingProfile objects, which determine whether composite children activites are tracked, what information is recorded, etc.
A TrackingParticipant is installed by adding it as an extension to the workflow application:
WorkflowApplication wfApp = new WorkflowApplication(myActivity);
It should be noted that Windows Server AppFabric has another separate WWF monitoring service that can be used.