找不到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性 [英] The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

查看:400
本文介绍了找不到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:


找不到来源,但部分或全部事件日志无法搜索
。无法访问的日志:安全性

The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security

当我运行下面的代码来捕获Win 2K12 R2服务器上的错误IIS 8.5

When I run below code to capture errors on Win 2K12 R2 server IIS 8.5

EventLog elog = new EventLog();
EventLog.CreateEventSource("MyApp", "Application");
EventLog.WriteEntry(Source, swError.ToString(), EventLogEntryType.Error);

我已经完全访问 HKLM \SYSTEM \ CurrentControlSet \\ \\services\eventlog 但它仍然没有工作。我该怎么做才能解决它?

I've given full access to HKLM\SYSTEM\CurrentControlSet\services\eventlog but it is not working still. What shall I do to fix it?

推荐答案

参见创建注册表项

此问题不仅可能由于权限而发生,还可能由于事件源密钥丢失而导致未成功注册(您需要管理员权限才能执行此操作)如果您像往常一样打开Visual Studio并正常运行程序,那就不够了)。确保您的事件源MyApp实际已注册,即它出现在注册表中的 HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet \ services \eventlog \ Application

This problem can occur not only due to permissions, but also due to event source key missing because it wasn't registered successfully (you need admin privileges to do it - if you just open Visual Studio as usual and run the program normally it won't be enough). Make sure that your event source "MyApp" is actually registered, i.e. that it appears in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application.

来自 MSDN EventLog.CreateEventSource()


在Windows Vista及更高版本中创建事件源或Windows Server
2003,您必须具有管理权限。

To create an event source in Windows Vista and later or Windows Server 2003, you must have administrative privileges.

因此您必须以管理员身份运行事件源注册码(另外,检查源是否已经存在 - 请参阅上面的MSDN示例)或者您可以手动将密钥添加到注册表中:

So you must either run the event source registration code as an admin (also, check if the source already exists before - see the above MSDN example) or you can manually add the key to the registry:


  1. 创建一个regkey HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet \services \eventlog \ Application \ MyApp ;

  2. inside,create字符串值事件MessageFile 并将其值设置为例如 C:\ Windows \ Microsoftoft.NET\Framework\v2.0.50727\EventLogMessages.dll

  1. create a regkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\MyApp;
  2. inside, create a string value EventMessageFile and set its value to e.g. C:\Windows\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll

这篇关于找不到源,但无法搜索部分或全部事件日志。无法访问的日志:安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆