Bewerken

Delen via


Can I see trace messages as they are generated?

Yes. To view trace messages as they are generated, use the real-time trace session options in TraceView, Tracelog, or Tracefmt. These tools are included in the tools\tracing\<Platform> subdirectory of the Microsoft Windows Driver Kit (WDK), where <Platform> is either i386, amd64, or ia64.

Trace providers do not have to include any special code to support real-time tracing.

TraceView

TraceView can start a real-time trace session that displays the trace messages as they are generated. To use TraceView for real-time monitoring:

  1. Start TraceView.

  2. On the File menu, click Create New Log Session.

  3. Click Add Provider.

  4. Select the CTL (Control GUID) File option. Then click the ellipsis button (...) to locate a control GUID file for the provider.

  5. Click Select TMF Files.

  6. Click Add, locate a trace message format (.tmf) file for the provider, click Open, and then click Done.

  7. Click Next.

  8. On the Log Session Options page, verify that the Real Time Display check box is selected (checked).

    You can select other options to specify trace flags and the trace level, or to customize the trace session.

  9. Click Finish.

For detailed information, in TraceView, on the Help menu, click Help Topics.

Tracelog

Tracelog can start, stop, and update a real-time trace session.

To start a real-time trace session by using Tracelog, use the -rt (real time) parameter in the command to start a trace session.

The following command starts a trace session called "My Trace" with providers whose control GUIDs are listed in the MyProvider.ctlcontrol GUID file. The -rt parameter specifies a real-time trace session.

tracelog -start MyTrace -guid MyProvider.ctl -rt

For a detailed example, see Example 10: Starting a Real-Time Trace Session.

To view the trace messages from a real-time trace session, use Tracefmt.

Tracefmt

Tracefmt can display trace messages from a real-time trace session. In real-time mode, Tracefmt formats and displays the messages as they are written to the file.

The following command displays the trace messages from the "MyTrace" real-time trace session. The -rt parameter specifies a real-time session. The -p parameter indicates the path of the trace message format (.tmf) file for the trace messages. The -display parameter directs Tracefmt to display the trace messages as they arrive from the buffer. The -o parameter specifies the location of the output file.

tracefmt -rt MyTrace -p c:\tracing -display -o mytrace.txt

For a detailed example, see Example 5: Formatting Real-Time Trace Sessions.