O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listeners Collection

Both the Debug and Trace classes have a static Listeners collection. This collection of TraceListeners represents a list of TraceListener objects that want to receive the output from the Debug or Trace class. Listeners are added to or removed from the collection just as with any other .NET collection.

 ' Create a listener that writes to the console Dim ConsoleOutput As New TextWriterTraceListener( _ Console.Out, "Console.Out Listener") Trace.Listeners.Add(ConsoleOutput) ' Create a listener that writes to a text file Dim OutputFile As Stream = File.Create("output.txt") Dim OutputFileListener As TextWriterTraceListener = New _ TextWriterTraceListener(OutputFile, _ "Output File Listener") Trace.Listeners.Add(OutputFileListener) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required