![](/img/trans.png)
[英]C# Unity JsonUtility, how can I turn this simple json into some kind of useful c# object?
[英]How can i write to the windows event log using C# (I'm getting some kind of error)?
我已经写了:
.
.
.
//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的读取权限。
作为回报,我得到:
The source was not found, but some or all event logs could not be searched. Inaccesible logs: Security.
有人知道为什么会这样吗?
HKEY_LOCAL_MACHINE \\ System \\ CurrentControlSet \\ Services \\ EventLog
需要做的是授予EventLog Key读取权限的“ Security ”子密钥。 之后,我重新启动了IIS。
如果您在要向其中写入事件日志的框上具有权限,则可以运行我编写的脚本 。
这篇kb的文章解释了赋予您的asp进程正确的安全权限以写入事件日志的步骤...
我认为在事件日志中创建源需要更高级别的访问。 对安全日志的引用可能是偶然的,它只是在报告可能的原因。 如果您以管理员身份创建自己的PodaHIS源,则可能会发现它可以对其进行写入。
您的部署环境是什么? 如果是Vista / Server 2008,则由于UAC无法将工作人员帐户添加到Administrators组中。
此链接详细说明了该问题。 但我建议尝试手动创建事件源,以便ASPNET无需创建它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.