When writing a custom TraceListener how can I force the writeheader, the data/messsage, and the writefooter to be one discreet record? Specifically the custom tracelisteners in question write to a non file based source, such as database or event stream. I need to either have the writeHeader, writefooter base methods in TraceListener be ignored or somehow packaged into a single write event.
When writing a custom TraceListener how can I force the writeheader, the data/messsage, and
Share
Here is a good article on how custom
TraceListeners work, which also explains when and whWriteHeaderandWriteFooterare called. The trick to avoidingWriteHeaderandWriteFooteris apparently to override the TraceData and/or TraceEvent calls.There is also some discussion of this issue in this SO thread.
Finally, I would encourage you to take a look at Ukadc.Diagnostics it is a pretty cool library for extending
System.Diagnosticsand provides, among other features, a nice way to achieve some log4net/NLog-like output formatting. There is a little bit of discussion about this library in this SO thread.Good luck!