gpt4 book ai didi

c# - 无法监控安全事件日志

转载 作者:可可西里 更新时间:2023-11-01 11:38:35 24 4
gpt4 key购买 nike

我有这个代码:

{
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 服务运行。我错过了什么?

最佳答案

确保设置 EnableRaisingEvents = true;

此外,在使用服务帐户运行之前,我会先将其作为普通应用程序运行。确保它不是在 LocalSystem 下运行,而是在为该服务定义为登录用户的其他用户下运行。您将看不到服务的 GUI,因此 Console.WriteLine 没有用。

关于c# - 无法监控安全事件日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5344366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com