.net - Windows, C#: reading eventlog entries from active AND saved logs -
i know can read security logs of windows pc using:
var securitylog = new eventlog("security"); foreach (eventlogentry entry in securitylog.entries) { ... }
the entry
item contains interesting log fields expect see like: instanceid
, message
, others. want read same things event log saved disk .evtx
file.
i have seen suggestions using
string xpathquery = "*"; var eventsquery = args.length == 0 ? new eventlogquery("security", pathtype.logname, xpathquery) : new eventlogquery(args[0], pathtype.filepath, xpathquery); using (var eventlogreader = new eventlogreader(eventsquery)) { eventlogrecord entry; while ((entry = (eventlogrecord) eventlogreader.readevent()) != null) { ... } }
but entry
in second version doesn't contain same members/values first example. totally dig confused , looking @ problem wrong way.
how should 1 go reading actual per record content either active or saved system log?
or, can go eventlogrecord
eventlogentry
? have not seen conversion method yet.
Comments
Post a Comment