Debug.Listeners Właściwość

Definicja

Pobiera kolekcję odbiorników monitorujących dane wyjściowe debugowania.

public:
 static property System::Diagnostics::TraceListenerCollection ^ Listeners { System::Diagnostics::TraceListenerCollection ^ get(); };
public static System.Diagnostics.TraceListenerCollection Listeners { get; }
static member Listeners : System.Diagnostics.TraceListenerCollection
Public Shared ReadOnly Property Listeners As TraceListenerCollection

Wartość właściwości

Reprezentująca TraceListenerCollection kolekcję typu TraceListener , która monitoruje dane wyjściowe debugowania.

Przykłady

Poniższy przykład powoduje utworzenie elementu wyjściowego TextWriterTraceListener na ekranie konsoli. Następnie kod dodaje nowy odbiornik do elementu Listeners.

/* Create a listener that outputs to the console screen, and
  * add it to the debug listeners. */
var myWriter = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(myWriter);
' Create a listener that outputs to the console screen, and 
' add it to the debug listeners. 
Dim myWriter As New TextWriterTraceListener(System.Console.Out)
Debug.Listeners.Add(myWriter)

Uwagi

Odbiorniki generują sformatowane dane wyjściowe z danych wyjściowych debugowania. Domyślnie kolekcja zawiera wystąpienie DefaultTraceListener klasy . Aby usunąć odbiornik domyślny, wywołaj metodę Remove i przekaż ją do wystąpienia klasy DefaultTraceListener. Aby przekierować dane wyjściowe do okna konsoli, dodaj wystąpienie klasy ConsoleTraceListener. Aby przekierować dane wyjściowe do pliku lub strumienia, dodaj wystąpienie klasy TextWriterTraceListener.

Note

Kolekcja Listeners jest współużytkowany przez klasy Debug i Trace ; dodanie odbiornika śledzenia do jednej z klas dodaje odbiornik do obu tych klas.

Dotyczy

Zobacz też