I'm working on a project that needs to check the Windows Event Log frequently for certain event. I'm wondering:
Is there a way to create a subscription of the Windows Event Log for certain event?
So, when the event happened (i.e. event id = 00001), I can get the notification in the code asap? I'm using c#. If this can not be done, then I will have to keep searching the event log which is not efficient.
Thanks
As you're using C#, I think you should use Windows API to subscribe to certain Windows events. You can do it by using either EventLogWatcher or EventLog class. You can find an example of creating a Windows Event Log subscription using EventLog on MSDN.
If you prefer EventLogWatcher, refer to its limited documentation. And here is my example: