I am working on a web application that displays event log data, similar to Event Viewer. The application should also enable users to subscribe to event logs and receive notifications when a record is written to signed logs using the web service.
I use this code to subscribe to an event log in a web service:
EventLog eventLog = new EventLog(observer.logName, observer.machineName);
eventLog.EnableRaisingEvents = true;
eventLog.EntryWritten += new EntryWrittenEventHandler(eventLog_EntryWritten);
eventList.Add(eventLog);
I am trying to use observers as event log subscribers, and when the EventWritten event is being processed, call the Update method for one observer. The problem is that I don’t know how to distinguish between event logs, since they all use the same event handler. I do this because the number of event logs differs from one computer to another. In addition, I want observers to process only one type of EventLog, i.e. one observer sends an email when an event is written to the application log.
I use this line of code to get all the logs on the current computer:
remoteEventLogs = EventLog.GetEventLogs(machineName);
EventWritten , Visual Studio EventLogInternal, , EventLog EventLog.Log. , :
void eventLog_EntryWritten(object sender, EntryWrittenEventArgs e)
{
var log = (EventLog)sender;
}
, , EventLogInternal EventLog.
, EventLog ?