ConsoleTraceListener ConsoleTraceListener ConsoleTraceListener ConsoleTraceListener Constructors

定義

オーバーロード

ConsoleTraceListener() ConsoleTraceListener() ConsoleTraceListener()

標準出力ストリームへのトレース出力を指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the ConsoleTraceListener class with trace output written to the standard output stream.

ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean)

トレース出力を標準出力ストリームまたは標準エラー ストリームに書き込むためのオプションを指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the ConsoleTraceListener class with an option to write trace output to the standard output stream or the standard error stream.

ConsoleTraceListener() ConsoleTraceListener() ConsoleTraceListener()

標準出力ストリームへのトレース出力を指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the ConsoleTraceListener class with trace output written to the standard output stream.

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

次のコード例ではConsoleTraceListener 、指定されConsoleた出力ストリームのオブジェクトを初期化し、それをトレースリスナーコレクションに追加します。The following code example initializes a ConsoleTraceListener object for the specified Console output stream and adds it to the trace listener collection. このコード例は、 ConsoleTraceListenerクラスに対して提供される大規模な例の一部です。This code example is part of a larger example provided for the ConsoleTraceListener class.

// 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)

注釈

このコンストラクターはConsoleTraceListenerConsole.Outストリームにメッセージを書き込むオブジェクトを初期化します。This constructor initializes a ConsoleTraceListener object to write messages to the Console.Out stream. このNameプロパティは、空の文字列 ("") に初期化されます。Its Name property is initialized to an empty string ("").

こちらもご覧ください

ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean) ConsoleTraceListener(Boolean)

トレース出力を標準出力ストリームまたは標準エラー ストリームに書き込むためのオプションを指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the ConsoleTraceListener class with an option to write trace output to the standard output stream or the standard error stream.

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

パラメーター

useErrorStream
Boolean Boolean Boolean Boolean

トレース出力およびデバッグ出力を標準エラー ストリームに書き込む場合は true。標準出力ストリームに書き込む場合は falsetrue to write tracing and debugging output to the standard error stream; false to write tracing and debugging output to the standard output stream.

次のコード例ではConsoleTraceListener 、指定されConsoleた出力ストリームのオブジェクトを初期化し、それをトレースリスナーコレクションに追加します。The following code example initializes a ConsoleTraceListener object for the specified Console output stream and adds it to the trace listener collection. このコード例は、 ConsoleTraceListenerクラスに対して提供される大規模な例の一部です。This code example is part of a larger example provided for the ConsoleTraceListener class.

// 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)

注釈

このコンストラクターは、 ConsoleTraceListenerオブジェクトを初期化して、 Console.OutまたはConsole.Errorストリームのいずれかにメッセージを書き込みます。This constructor initializes a ConsoleTraceListener object to write messages to either the Console.Out or the Console.Error stream. このNameプロパティは、空の文字列 ("") に初期化されます。Its Name property is initialized to an empty string ("").

こちらもご覧ください

適用対象