Question

have a requirement to write multiple data items into eventviewer <eventData> like below

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> 
   <System> 
       <Provider Name="Elib" /> 
       <EventID Qualifiers="0">0</EventID> 
       <Level>4</Level> 
       <Task>0</Task> 
       <Keywords>0x80000000000000</Keywords> 
       <TimeCreated SystemTime="2014-01-03T12:42:30.000000000Z" /> 
       <EventRecordID>33</EventRecordID> 
       <Channel>Elib</Channel> 
       <Computer>48vtvs1</Computer> 
       <Security /> 
   </System> 
   <EventData> 
       <Data>Entry1</Data> 
       <Data>Entry2</Data> 
   </EventData> 
</Event>

I am able to write multiple entries under <eventdata> with the help of below code

EventLog.WriteEvent("Application", 
new EventInstance(1001, 0, EventLogEntryType.Information), 
new object[] { "Entry1", "Entry2" });

output:

<EventData> 
   <Data>Entry1</Data> 
   <Data>Entry2</Data> 
</EventData> 

but my requirement is to add name attributes to data nodes like below

<EventData> 
<Data name="title">Entry1</Data> 
<Data name=Message">Entry2</Data> 
</EventData> 

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top