ConsoleTraceListener Konstruktory

Definice

Inicializuje novou instanci ConsoleTraceListener třídy.

Přetížení

ConsoleTraceListener()

Inicializuje novou instanci ConsoleTraceListener třídy s výstupem trasování zapsaným do standardního výstupního datového proudu.

ConsoleTraceListener(Boolean)

Inicializuje novou instanci ConsoleTraceListener třídy s možností zápisu výstupu trasování do standardního výstupního datového proudu nebo standardního datového proudu chyb.

ConsoleTraceListener()

Zdroj:
ConsoleTraceListener.cs
Zdroj:
ConsoleTraceListener.cs
Zdroj:
ConsoleTraceListener.cs

Inicializuje novou instanci ConsoleTraceListener třídy s výstupem trasování zapsaným do standardního výstupního datového proudu.

public:
 ConsoleTraceListener();
public ConsoleTraceListener ();
Public Sub New ()

Příklady

Následující příklad kódu inicializuje ConsoleTraceListener objekt pro zadaný Console výstupní stream a přidá ho do kolekce trasovacího naslouchacího procesu. Tento příklad kódu je součástí většího příkladu ConsoleTraceListener pro třídu.

// Define a trace listener to direct trace output from this method
// to the console.
ConsoleTraceListener consoleTracer;

// Check the command line arguments to determine which
// console stream should be used for trace output.
if ((CmdArgs.Length>0)&&(CmdArgs[0].ToString().ToLower().Equals("/stderr")))
    // Initialize the console trace listener to write
    // trace output to the standard error stream.
{
    consoleTracer = new ConsoleTraceListener(true);
}
else
{
    // Initialize the console trace listener to write
    // trace output to the standard output stream.
    consoleTracer = new ConsoleTraceListener();
}
// Set the name of the trace listener, which helps identify this
// particular instance within the trace listener collection.
consoleTracer.Name = "mainConsoleTracer";

// Write the initial trace message to the console trace listener.
consoleTracer.WriteLine(DateTime.Now.ToString()+" ["+consoleTracer.Name+"] - Starting output to trace listener.");

// Add the new console trace listener to
// the collection of trace listeners.
Trace.Listeners.Add(consoleTracer);
' Define a trace listener to direct trace output from this method
' to the console.
Dim consoleTracer As ConsoleTraceListener

' Check the command line arguments to determine which
' console stream should be used for trace output.
If (CmdArgs.Length > 0) AndAlso _
   (CmdArgs(0).ToLower.Equals("/stderr")) Then
    ' Initialize the console trace listener to write
    ' trace output to the standard error stream.
    consoleTracer = New ConsoleTraceListener(True)
Else
    ' Initialize the console trace listener to write
    ' trace output to the standard output stream.
    consoleTracer = New ConsoleTraceListener
End If
' Set the name of the trace listener, which helps identify this 
' particular instance within the trace listener collection.
consoleTracer.Name = "mainConsoleTracer"

' Write the initial trace message to the console trace listener.
consoleTracer.WriteLine(DateTime.Now.ToString() & " [" & _
     consoleTracer.Name & "] - Starting output to trace listener.")

' Add the new console trace listener to 
' the collection of trace listeners.
Trace.Listeners.Add(consoleTracer)

Poznámky

Tento konstruktor inicializuje ConsoleTraceListener objekt pro zápis zpráv do datového Console.Out proudu. Jeho Name vlastnost je inicializována na prázdný řetězec ("").

Viz také

Platí pro

ConsoleTraceListener(Boolean)

Zdroj:
ConsoleTraceListener.cs
Zdroj:
ConsoleTraceListener.cs
Zdroj:
ConsoleTraceListener.cs

Inicializuje novou instanci ConsoleTraceListener třídy s možností zápisu výstupu trasování do standardního výstupního datového proudu nebo standardního datového proudu chyb.

public:
 ConsoleTraceListener(bool useErrorStream);
public ConsoleTraceListener (bool useErrorStream);
new System.Diagnostics.ConsoleTraceListener : bool -> System.Diagnostics.ConsoleTraceListener
Public Sub New (useErrorStream As Boolean)

Parametry

useErrorStream
Boolean

true k zápisu výstupu trasování a ladění do standardního datového proudu chyb; false k zápisu výstupu trasování a ladění do standardního výstupního datového proudu.

Příklady

Následující příklad kódu inicializuje ConsoleTraceListener objekt pro zadaný Console výstupní stream a přidá ho do kolekce trasovacího naslouchacího procesu. Tento příklad kódu je součástí většího příkladu ConsoleTraceListener pro třídu.

// Define a trace listener to direct trace output from this method
// to the console.
ConsoleTraceListener consoleTracer;

// Check the command line arguments to determine which
// console stream should be used for trace output.
if ((CmdArgs.Length>0)&&(CmdArgs[0].ToString().ToLower().Equals("/stderr")))
    // Initialize the console trace listener to write
    // trace output to the standard error stream.
{
    consoleTracer = new ConsoleTraceListener(true);
}
else
{
    // Initialize the console trace listener to write
    // trace output to the standard output stream.
    consoleTracer = new ConsoleTraceListener();
}
// Set the name of the trace listener, which helps identify this
// particular instance within the trace listener collection.
consoleTracer.Name = "mainConsoleTracer";

// Write the initial trace message to the console trace listener.
consoleTracer.WriteLine(DateTime.Now.ToString()+" ["+consoleTracer.Name+"] - Starting output to trace listener.");

// Add the new console trace listener to
// the collection of trace listeners.
Trace.Listeners.Add(consoleTracer);
' Define a trace listener to direct trace output from this method
' to the console.
Dim consoleTracer As ConsoleTraceListener

' Check the command line arguments to determine which
' console stream should be used for trace output.
If (CmdArgs.Length > 0) AndAlso _
   (CmdArgs(0).ToLower.Equals("/stderr")) Then
    ' Initialize the console trace listener to write
    ' trace output to the standard error stream.
    consoleTracer = New ConsoleTraceListener(True)
Else
    ' Initialize the console trace listener to write
    ' trace output to the standard output stream.
    consoleTracer = New ConsoleTraceListener
End If
' Set the name of the trace listener, which helps identify this 
' particular instance within the trace listener collection.
consoleTracer.Name = "mainConsoleTracer"

' Write the initial trace message to the console trace listener.
consoleTracer.WriteLine(DateTime.Now.ToString() & " [" & _
     consoleTracer.Name & "] - Starting output to trace listener.")

' Add the new console trace listener to 
' the collection of trace listeners.
Trace.Listeners.Add(consoleTracer)

Poznámky

Tento konstruktor inicializuje ConsoleTraceListener objekt pro zápis zpráv do datového Console.OutConsole.Error proudu nebo. Jeho Name vlastnost je inicializována na prázdný řetězec ("").

Viz také

Platí pro