I have this code:
{
EventLog ev = new EventLog("Security");
ev.EntryWritten += new EntryWrittenEventHandler(ev_EntryWritten);
}
static void ev_EntryWritten(object sender, EntryWrittenEventArgs e)
{
log_to_file("ev_EntryWritten");
}
开发者_如何学运维
But I receive no security events whatsoever. The program runs as a Windows Service on XP SP3. What am I missing?
Make sure you set EnableRaisingEvents = true;
Also, I would run it as a normal application first prior to running it under a service account. Make sure it isn't running under LocalSystem but some other user that is defined for that service as the logon user. You will not see GUI for a service so Console.WriteLine
is useless.
精彩评论