June 2002
Intermediate to advanced
864 pages
18h 35m
English
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) ...Read now
Unlock full access