I'm trying to create a simplified API for both logging (errors, warnings, info) and tracing (debug, analytics) to the Windows Event Log so I can use Windows Event Viewer to work with the logs. I found the EventLog class and started coding against it, and it works for logging to the Application log. I can't find any documentation on specifying the log subcategory with this class, though. I need to push trace info to the Analytic and Debug logs, and I'd like to let the application choose whether logged events go to the Admin or Operational logs.
I then learned about the EventSource class, and various blogs on MSDN indicate that it does allow you to specify the logging "channel", but I don't know whether the channel is another word for the log subcategory.
This is the only thread I could find comparing the two classes, and it didn't seem to answer what I need to know:
- Can I use either EventLog or EventSource for logging to a specific to WEL subcategory?
- Is one of them recommended over the other in the .NET 4.5 framework? i.e. is EventLog considered to be deprecated, or is it meant only for non-trace use?