I want to read an archived Windows event log file (.evtx
), like in this example:
using System;
using System.Diagnostics.Eventing.Reader;
public static class Program {
static void Main(string[] args) {
using (var reader = new EventLogReader(@"C:\tmp\some-log.evtx", PathType.FilePath)) {
EventRecord record;
while ((record = reader.ReadEvent()) != null) {
// do something with record...
}
}
}
}
The record
object has a Properties
list that contains the replacement strings for the event:
foreach (var property in record.Properties) {
Console.WriteLine(property.Value);
}
If I open the .evtx
file in the event log viewer, I can see a full description for the event, which is like a base template message (which should come from a resources file associated to the application that generated the event) with the values for the placeholders replaced with those values:
Is there a way I can get this "message template" for a certain event?