6

Is there a way to watch events of "applications and services" when they are generated (in C#)? I've figured out that I can not use WMI for it.

Any other ideas?

user1011394
  • 1,656
  • 6
  • 28
  • 41

2 Answers2

6

You can subscribe to EventLog.EntryWritten Event

Occurs when an entry is written to an event log on the local computer.

From MSDN:

    ....
    EventLog myNewLog = new EventLog();
    myNewLog.Log = "MyCustomLog";                      

    myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
    myNewLog.EnableRaisingEvents = true;                 

}       

public static void MyOnEntryWritten(object source, EntryWrittenEventArgs e){

}
Raj Ranjhan
  • 3,869
  • 2
  • 19
  • 29
1

Did your try it wit the EventLog.EntryWritten Event?

shriek
  • 5,157
  • 2
  • 36
  • 42