c# - How to find out EventProperty name? -


my c# application subscribes windows event log messages:

var subscriptionquery = new eventlogquery(settings.default.logpath, pathtype.logname, settings.default.logquery); _watcher = new eventlogwatcher(subscriptionquery); _watcher.eventrecordwritten += eventlogeventread; 

when message occurs eventlogeventread handler reseives system.diagnostics.eventing.reader.eventlogrecord object, containing event data. information includes collection of eventproperty objects. problem is: eventproperty defines value, not name of property. however, when open same event in windows event log viewer, shows properties names. question is: how event propery names?

there 2 ways go (that know of), both involve parsing xml.

eventrecord has function toxml includes userdata section, containing values block.

the other option bit more complicated: create providermetadata, find eventmetadata describes current eventrecord, , parse template member. template member explains how interpret values (even including types), in xml format.

var meta = new providermetadata(record.providername).events.where(evt => evt.id == eventrecord.id).firstordefault();


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -