Links : Part 1, Part 2, Part 3
Working with event trace sessions : Create and configuring trace sessions
Let see how to create trace sessions using a GUI based controller application. This GUI based controller application is non other than our perfmon.exe. Use the following steps to create new trace session for your custom provider.
- Open performance monitor by running the perfmon.exe in command prompt.
- Once performance monitor is opened, browse to Event Trace Sessions tree node. You will see Trace Sessions already configured to listen for event from system event providers. Our goal is to create a similar kind of trace session for our custom provider.
- Right click on the right panel and click on New-> Data Collector Set. This will open 'Create New Data Collector Set' wizard.
Wizard window.
- Provide Trace session name as 'Trace session for custom provider'. Click on 'Next' to open provider selection wizard view.
- Click on 'Add' and select your custom provider from the list operating system has enumerated for all the registered providers. Our provider will also be listed here as we have already register it with the system. Click Ok to confirm the provider selection.
- Configure the trace session by customizing it to listen for specific keywords and verbosity levels. Select the keywords row from Properties list and click on 'Edit' button to view the available keyword name. In our case we see only two keywords which we defined in instrumentation manifest file.
Enable the check option for both the keywords values.
Similarly configure the required levels as well. After the configuration your wizard view show look as following.
Click on 'Next' button.
- Provide directory path where your want to save the collected events data. What value you give here is important in case you want to view your events using Windows Event Viewer. To view your events using Event Viewer you must provider following directory path to save the events data.
%SystemRoot%\System32\Winevt\Logs\
Wizard view after providing the directory path.
Click on 'Next' button.
- Change the option to 'Start this collector set now' as show in below image and click 'Finish' button.
We are done with creating trace session and it is up and running. Ready to listen for the event published by your custom provider.
At this point if you run the console application we created, trace session will collect all the published events this application will fire.
Working with Consumer application
Once we have create a trace session for a event provider, all the events from that provider are collected via trace sessions and are logged in log files. We will use Windows Event Viewer as Consumer application to view all the published events from our console application. Use the following steps to view the events.
- Open Windows Event Viewer by running eventvwr.exe in command prompt.
- Expand 'Applications and Services Logs' node. You will see a new entry has been created for the channel you had defined in instrumentation manifest file. Expand 'Working with ETW provider' and select 'Analytic' node to view all the events published by our console application .
No comments:
Post a Comment