TraceLogging Reference

The following topics provide information about the C/C++ TraceLogging API.

Note

If you are generating events from C/C++ code and the events are defined at compile-time, use the APIs described in this section. Otherwise, if you are generating events from .NET code, use the .NET EventSource class. Otherwise, if you are using Windows Runtime (WinRT), use LoggingChannel. Otherwise, you might be able to use a community-supported option such as TraceLoggingDynamic.

TraceLogging builds on Event Tracing for Windows (ETW) and is easier to use than manifest-based ETW or WPP. TraceLogging allows you to generate events that include structured data, supports event correlation using ETW activities, and does not require a separate instrumentation manifest XML file for decoding.

TraceLoggingProvider.h is the recommended API for C/C++ developers in user or kernel mode. The following links describe the C/C++ API.

Note that the value of WINVER (user-mode) will affect the way TraceLoggingProvider.h behaves:

  • If WINVER is not set before including <windows.h>, then <windows.h> will set WINVER to a default value corresponding to the SDK version.
  • If you use TraceLoggingProvider.h with WINVER set to 0x0602 (Windows 8) or higher, the program may not run on Windows Vista or Windows 7 (TraceLoggingProvider.h will try to directly use the EventSetInformation, which was not present in RTM versions of Windows Vista or Windows 7).
  • If you use TraceLoggingProvider.h with WINVER set to 0x0600 (Windows Vista) or 0x0601 (Windows 7), the program will be configured for compatibility and will work on the specified versions of Windows (TraceLoggingProvider.h will invoke EventSetInformation via GetProcAddress if available).