Eventlog listener - Applications and Services

扶醉桌前 提交于 2019-11-30 05:27:33

问题


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?


回答1:


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){

}



回答2:


Did your try it wit the EventLog.EntryWritten Event?



来源:https://stackoverflow.com/questions/10129446/eventlog-listener-applications-and-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!