.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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -