Whilst the Ent Lib 5 is very easy to get logging working; when the data is logged to the event log it is in the format (as seen via XML tab> as <EventData> A B C D </>" . I need to get it in the form <EventData><Data Name=A/><Data Name=B/>....". Does anyone know if there a way of doing this using the Ent Lib 5 logging block or the like...
Asked
Active
Viewed 352 times
1 Answers
0
You can customize your text formatter for writing it as xml. Something like this:
<add template="<Timestamp>{timestamp}</Timestamp>" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging" name="Text Formatter" />
So the output is something like:
<EventData><Data><Timestamp>2/13/2013 7:59:32 PM</Timestamp></Data></EventData>
If you want to serialize an object to xml you can write a custom formatter and use it. Derive it from LogFormatter and override the Format method. And serialize your LogEntry to xml.

animuson
- 53,861
- 28
- 137
- 147

Yusuf Uzun
- 1,491
- 1
- 13
- 32