I want to programmatically get the event log that appears in a folder in eventvwr. This one is for Windows 8 Apps: Microsoft-Windows-AppHost/Admin. I’m running as Admin.
This is not working:
System.Diagnostics.EventLog.SourceExists("Microsoft-Windows-AppHost/Admin");
This is not working either:
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;
You can read the event log using this code:
If you want to attach your handler, your code is close, but you can simply pass the string into the watcher, instead of using the query object: