Programming with Trace Listeners

Trace and Debug text has to go somewhere. We already know that by default Write and WriteLine information is displayed in the Output window. The Output window and other such recipients of Trace and Debug information are referred to as trace listeners.

It is clearly possible that some internal mechanism writes to the Output window directly, but this isn't exactly what happens. Both the Trace and Debug classes have a Listeners property that is a collection. Trace and Debug share the same underlying Listeners collection, so adding a listener to one class—for example, Trace.Listeners—effectively adds a listener to the other. There are four possible kinds of listeners: DefaultTraceListener (which is comprised of the ...

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.