![](/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.