写入 Windows 事件日志时出现错误消息
当我运行我编写的一段代码时,我不断收到以下错误:
未找到来源,但有一些或 无法搜索所有事件日志。 无法访问的日志:安全性。
我已经仔细检查过,并且没有在任何地方手动写入日志,因此我假设我的应用程序是自己执行此操作的。
我发现这篇文章,这建议我给予读/写与事件日志对应的注册表项的权限。我对此有三个问题:
这是解决此问题的正确方法吗 错误?
如果我选择这条路线,我是否应该向运行我的应用程序池的任何内容授予权限? (它是一个网络应用程序)
授予对该注册表项的读/写访问权限是否安全?
When I run a piece of code that I wrote I keep getting the following error:
The source was not found, but some or
all event logs could not be searched.
Inaccessible logs: Security.
I have double checked and I am not manually writing to the logs anywhere, so I assume my application is doing it on it's own.
I found this post, which suggest that I give read/write permissions to a registry entry that corresponds to the Event Logs. I had three questions about this:
Is this the correct way to fix this
error?If I go this route, should I give permissions to whatever my app pool is running under? (it's a web app)
Is it secure to give read/write access to that registry key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来绝对是一个权限问题。这与您尝试写入事件日志的源尚不存在有关。一旦创建,这个错误就会消失。由于您只需要确保第一次添加源,因此您可以尝试注册表方法(向 AppPool 用户授予访问权限),然后在创建源后删除注册表访问权限。
我通过使用我编写的以管理员身份运行的对话框应用程序手动将源添加到事件日志来解决此问题。添加源后,所有其他事件日志记录都可以正常工作。如果您知道它在写入事件日志时尝试使用的源,您也可以尝试该方法。
This definitely seems like a permissions issue. It has to do with the fact that the Source you are trying to write into the event log does not already exist. Once it is created, this error should go away. Since you just need to make sure the Source gets added that first time, you could try the registry approach (grant access to the AppPool user), and then remove the registry access after the source has been created.
I've worked around this issue by manually adding the Source to the Event Log using a dialog app I wrote that I run as Administrator. Once the Source is added, all of the other event logging works fine. If you know the Source that it's trying to use when it writes to the event log, you could try that approach as well.