无法监控安全事件日志
我有这个代码:
{
EventLog ev = new EventLog("Security");
ev.EntryWritten += new EntryWrittenEventHandler(ev_EntryWritten);
}
static void ev_EntryWritten(object sender, EntryWrittenEventArgs e)
{
log_to_file("ev_EntryWritten");
}
但我没有收到任何安全事件。该程序在 XP SP3 上作为 Windows 服务运行。我缺少什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保设置
EnableRaisingEvents = true;
另外,我会先将其作为普通应用程序运行,然后再在服务帐户下运行它。确保它不是在 LocalSystem 下运行,而是在为该服务定义为登录用户的其他用户下运行。您将看不到服务的 GUI,因此
Console.WriteLine
毫无用处。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.