Need to log to textbox and not use config

Topics: Logging Application Block
Oct 24, 2007 at 12:34 PM
Hi all

I have a requirement to log to a text box. In itself this is not too dificult as i can write a tracelistener that fires events with the data. However the logging sources are entlib and i cant touch the config file - the customer may be using ent lib already or they may not ...

Will it work just loading the listener with Trace.Listeners.Add ?

Regards,

Ben
Oct 25, 2007 at 5:14 AM
Hi Ben,

Updating the listeners collection from the Trace class will not help; the logging block uses a different set of listener instances.

A simple but not very elegant approach is to rely on static registration. You would create your trace listener, and have it write its entries by say firing an event. This event would be defined as static in the listener class, and your UI would register a delegate that would write to the text box. Not pretty, but would do the trick.

Fernando