【发布时间】:2016-01-08 10:30:15
【问题描述】:
我正在 VS.NET 2010 / C# 中创建一个使用事件日志组件进行日志记录的 Windows 服务。我创建了事件源,并且该服务在本地系统帐户下运行,因此不会发生与安全相关的问题。
虽然我确实在 Visual Studio 2010(服务器浏览器)的事件日志视图中看到了我的事件,但我在 Windows 的标准事件日志实用程序中看不到它们。有什么问题?我的代码如下。提前感谢您的帮助!
public Service()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("Photo Processing Service"))
{
System.Diagnostics.EventLog.CreateEventSource(
"Photo Processing Service", "fexpress");
}
fexpressLog.Source = "Photo Processing Service";
fexpressLog.Log = "fexpress";
}
那么……
fexpressLog.WriteEntry (...);
【问题讨论】:
-
它为你创建了日志吗?
-
我是在另一个脚本的帮助下自己完成的:myEventLogInstaller = new EventLogInstaller(); myEventLogInstaller.Source = "照片处理服务"; myEventLogInstaller.Log = "fexpress"; Installers.Add(myEventLogInstaller);
-
我有同样的问题 - windows7 32bit - 你可以在以下目录中查看是否存在与你的日志对应的 .evtx 文件:C:\Windows\System32\winevt\Logs
标签: c# windows-services event-log