Search code examples
etw

Can you use custom keywords with ETW


Is it possible to use custom keywords with ETW?

I'm using ETW for logging/tracing/diagnostics in my application and I'd like the ability to assign keywords for easier querying of the logs. Diagnostics, Timed Event, Information, and others that are more specific such as DB Connection or whatever.


Solution

  • Yes, this is possible when you use the EventSource Package:

    public class Keywords   // This is a bitvector
    {
        public const EventKeywords Requests = (EventKeywords)0x0001;
        public const EventKeywords Debug = (EventKeywords)0x0002;
    }
    

    This is also explained in the _EventSourceUsersGuide.docx which you can find in your solution after adding the NuGet package.