ConsoleTraceListener コンストラクター

定義

ConsoleTraceListener クラスの新しいインスタンスを初期化します。

オーバーロード

ConsoleTraceListener()

標準出力ストリームへのトレース出力を指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。

ConsoleTraceListener(Boolean)

トレース出力を標準出力ストリームまたは標準エラー ストリームに書き込むためのオプションを指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。

ConsoleTraceListener()

標準出力ストリームへのトレース出力を指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。

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

次のコード例では、 ConsoleTraceListener 指定した Console 出力ストリームのオブジェクトを初期化し、トレース リスナー コレクションに追加します。 このコード例は、ConsoleTraceListener クラスのために提供されている大規模な例の一部です。

// 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 初期化します。 その Name プロパティは空の文字列 ("") に初期化されます。

こちらもご覧ください

適用対象

ConsoleTraceListener(Boolean)

トレース出力を標準出力ストリームまたは標準エラー ストリームに書き込むためのオプションを指定して、ConsoleTraceListener クラスの新しいインスタンスを初期化します。

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

パラメーター

useErrorStream
Boolean

トレース出力およびデバッグ出力を標準エラー ストリームに書き込む場合は true。標準出力ストリームに書き込む場合は false

次のコード例では、 ConsoleTraceListener 指定した Console 出力ストリームのオブジェクトを初期化し、トレース リスナー コレクションに追加します。 このコード例は、ConsoleTraceListener クラスのために提供されている大規模な例の一部です。

// 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.ErrorConsole.Out初期化します。 その Name プロパティは空の文字列 ("") に初期化されます。

こちらもご覧ください

適用対象