本文介绍了我为什么能写入使用C#(我得到了某种错误)的Windows事件日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经写:
.
.
.
//Log exception to the event log
if (!EventLog.SourceExists("PodaHIS")) {
EventLog.CreateEventSource("PodaHIS", "Application");
}
EventLog eventLog = new EventLog();
eventLog.Log = "Application";
eventLog.Source = "PodaHIS";
eventLog.WriteEntry(error.ToString(), EventLogEntryType.Error);
我也可以读取权限LOCALMACHINE\ASPNET。
I have also enabled read permission to LOCALMACHINE\ASPNET.
和回报,我得到:
The source was not found, but some or all event logs could not be searched. Inaccesible logs: Security.
有谁知道为什么发生这种情况?
Does anyone know why this is happening?
推荐答案
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog
什么是需要做的是给予安全子键读取权限。从那以后,我重新启动我的IIS。
What is need to do was grant the "Security" sub key of the EventLog Key read permission. After that i restarted my IIS.
这篇关于我为什么能写入使用C#(我得到了某种错误)的Windows事件日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!