我想以编程方式获取出现在 eventvwr 文件夹中的事件日志。这个适用于 Windows 8 应用程序:Microsoft-Windows-AppHost/Admin。我以管理员身份运行。
这不起作用:
System.Diagnostics.EventLog.SourceExists("Microsoft-Windows-AppHost/Admin");
这也不起作用:
EventLogQuery queryMicrosoftWindowsAppHost = new EventLogQuery("Microsoft-Windows-AppHost/Admin", PathType.LogName);
_eventsMicrosoftWindowsAppHost = new List<EventRecordWrittenEventArgs>();
_eventLogWatcherMicrosoftWindowsAppHost = new EventLogWatcher(queryMicrosoftWindowsAppHost);
_eventLogWatcherMicrosoftWindowsAppHost.EventRecordWritten += (object sender, EventRecordWrittenEventArgs e) =>
{
_eventsMicrosoftWindowsAppHost.Add(e);
};
_eventLogWatcherMicrosoftWindowsAppHost.Enabled = true;