繁体   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