簡體   English   中英

WCF服務不寫入事件日志

[英]WCF Service not writing to Event Log

下面是我用來初始化事件日志的代碼,下面是我用來寫入日志的代碼示例。

private string sSource = "DaVinci";
private string sLog = "WCF WebService";

//Initialize Event Log
if(!EventLog.SourceExists(sSource)) EventLog.CreateEventSource(sSource, sLog);

//Write openining message
EventLog.WriteEntry(sSource, "Opening WCF Service", EventLogEntryType.Warning);

但是,該程序當前沒有寫入日志,因為它已被指示執行。 沒有任何類型的消息被寫入。 任何人都可以看到上面的代碼有什么問題或提供任何關於在哪里尋找問題的建議?

是的,sLog應該是您要在事件查看器中寫入的日志類型。 例如, Application會將其寫入Windows Logs下的Application日志。

編輯:您可能無權創建事件源。 嘗試將此密鑰添加到您的注冊表: [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\YourSourceNameHere]

此外,如果您沒有以管理員身份運行應用程序,請嘗試這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM