NTrace uses the same tools that WPP tracing uses to capture trace logs: traceog.exe starts and stops tracing sessions, tracefmt.exe transforms the binary logs that ETW generates into human-readable text, and TraceView.exe is a GUI that
performs the same functions as the previous two command-line apps. In this case, let’s use TraceView to start a new real-time logging session.
Obtaining the provider ID
When we created our application, the project template generated a unique identifier to be used as the application’s ETW provider ID. We’ll need to get that in order to tell TraceView what provider to listen for. To do that, merely open the project properties,
click the NTrace tab, and copy the value of the Etw Provider Id property:
Running a real-time trace with TraceView
We can now start TraceView and choose “Create New Trace Session” from the File Menu:
Once we’ve clicked that menu item, we will be presented with a “Create New Log Session” dialog. Now we need to add our provider ID to the list by clicking the “Add Provider” button.
We are then presented with a dialog asking us what trace provider we’ll be using. In this case, we have our provider ID:
After we click the OK, button, we are then prompted for where TraceView will get the formatting information. In this case, we’ll choose “Select TMF Files.”
At this point, we are prompted with a dialog requesting the location TraceView should use to search for TMF files to use to generate the human-readable text. The NTrace preprocessor currently places the TMF and TMC files in the Trace folder for the current
configuration’s output folder. In this case, we’ll use the files generated during the Debug build, so we’ll navigate to the bin\Debug\Trace folder and click OK.
This returns us to the “Create New Log Session” dialog:
After clicking the Next button, we are presented with the final step: we need to choose whether we’ll view the trace session in real time, or if we will log to a file. In this case, we want to see the log messages in real time, so we’ll ensure that checkbox
There! We’ve created our log session and it is now waiting for trace messages to arrive:
We can now run our application and see trace messages appear in the console: