In wf4, the tracking service is used to track the tracing records that the participants directly listen to during running and process them according to the selected method. We can record logs to different media. In this article, we will look at the ETW tracking participants supported by wf4.
Windows event tracking (ETW) is a high-speed and common tracking tool provided by the operating system. ETW uses the buffer and logging mechanism implemented in the kernel to provide user-mode applications.ProgramAnd the tracking mechanism of events caused by kernel-mode device drivers. In addition, ETW allows you to dynamically enable and Disable Logging and easily perform detailed tracing in the actual production environment without restarting the system or applications. The logging mechanism uses the buffer of each processor, which is written to the disk by the asynchronous write thread. In this way, the interference of Large server applications when writing events can be minimized.
We create a workflow project. In the workflow design, we can add a few activities as needed, as shown below:
Let's take a look at how to configure the ETW tracking,CodeAs follows:
// ETW tracking setup
Trackingprofile = new trackingprofile ();
Trackingprofile. Queries. Add (New workflowinstancequery
{
States = {"*"}
});
Trackingprofile. Queries. Add (New activitystatequery
{
States = {"*"}
});
Trackingprofile. Queries. Add (New customtrackingquery
{
Activityname = "*",
Name = "*"
});
Etwtrackingparticipant ipant = new etwtrackingparticipant ipant ();
Etwtrackingparticipant ipant. trackingprofile = trackingprofile;
In the above code, we can choose to record the tracing information, which is completed by tracking the configuration file and can be customized according to your needs, after that, we need to add etwtrackingparticipant ipant to the workflow as an extension point. The Code is as follows:
Autoresetevent = new autoresetevent (false );
Workflowapplication = new workflowapplication (New workflow1 ());
Workflowapplication. Completed = (ARG) =>{ autoresetevent. Set ();};
Workflowapplication. Extensions. Add (etwtrackingparticipant ipant );
Workflowapplication. Run ();
Autoresetevent. waitone ();
Then we run the workflow, and the result is very simple:
Open the windows Event Viewer and switch to the location where relevant information is recorded. This is the information after the workflow is run:
We can see the details of Workflow running as follows: