TraceListener クラス
定義
トレース出力およびデバッグ出力を監視するリスナーの abstract
基本クラスを提供します。Provides the abstract
base class for the listeners who monitor trace and debug output.
public ref class TraceListener abstract : MarshalByRefObject, IDisposable
public ref class TraceListener abstract : IDisposable
public abstract class TraceListener : MarshalByRefObject, IDisposable
public abstract class TraceListener : IDisposable
type TraceListener = class
inherit MarshalByRefObject
interface IDisposable
type TraceListener = class
interface IDisposable
Public MustInherit Class TraceListener
Inherits MarshalByRefObject
Implements IDisposable
Public MustInherit Class TraceListener
Implements IDisposable
- 継承
- 継承
-
TraceListener
- 派生
- 実装
注釈
を実装する方法の例については、 TraceListener 「」 DefaultTraceListener TextWriterTraceListener およびクラスを参照してください EventLogTraceListener 。For examples of how to implement a TraceListener, see the DefaultTraceListener, TextWriterTraceListener and the EventLogTraceListener classes.
トレースリスナーを使用するには、トレースまたはデバッグを有効にする必要があります。You must enable tracing or debugging to use a trace listener. 次の構文はコンパイラ固有です。The following syntax is compiler specific. C# または Visual Basic 以外のコンパイラを使用する場合は、コンパイラのドキュメントを参照してください。If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.
C# でのデバッグを有効にするに
/d:DEBUG
は、コードをコンパイルするときにコンパイラのコマンドラインにフラグを追加するか、#define DEBUG
ファイルの先頭にを追加します。To enable debugging in C#, add the/d:DEBUG
flag to the compiler command line when you compile your code, or you can add#define DEBUG
to the top of your file. Visual Basic で、コンパイラの/d:DEBUG=True
コマンドラインにフラグを追加します。In Visual Basic, add the/d:DEBUG=True
flag to the compiler command line.C# でトレースを有効にするに
/d:TRACE
は、コードをコンパイルするときにコンパイラのコマンドラインにフラグを追加するか、#define TRACE
ファイルの先頭にを追加します。To enable tracing in C#, add the/d:TRACE
flag to the compiler command line when you compile your code, or add#define TRACE
to the top of your file. Visual Basic で、コンパイラの/d:TRACE=True
コマンドラインにフラグを追加します。In Visual Basic, add the/d:TRACE=True
flag to the compiler command line.
トレースリスナーを追加するには、アプリケーションの名前に対応する構成ファイルを編集します。To add a trace listener, edit the configuration file that corresponds to the name of your application. このファイル内で、リスナーを追加したり、その型を設定したり、パラメーターを設定したり、リスナーを削除したり、アプリケーションによって以前に設定されたすべてのリスナーをクリアしたりできます。Within this file, you can add a listener, set its type and set its parameter, remove a listener, or clear all the listeners previously set by the application. 構成ファイルは、次の例のように書式設定する必要があります。The configuration file should be formatted similar to the following example.
<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
トレースに構成ファイルを使用する方法の詳細については、「 < システム診断 > 」を参照してください。For more information on using configuration files for tracing, see <system.diagnostics>.
注意 (実装者)
クラスとクラスのカスタムリスナーを実装するには、このクラスから継承し Debug Trace ます。Inherit from this class to implement a custom listener for the Debug and Trace classes. 少なくとも、メソッドとメソッドを実装する必要があり Write(String) WriteLine(String) ます。At a minimum, you must implement the Write(String) and WriteLine(String) methods. また、、、およびの各メソッドを実装することもでき Fail(String) Close() Flush() ます。Additionally, you can implement the Fail(String), Close() and Flush() methods.
コンストラクター
TraceListener() |
TraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the TraceListener class. |
TraceListener(String) |
指定した名前をリスナーとして使用して、TraceListener クラスの新しいインスタンスを初期化します。Initializes a new instance of the TraceListener class using the specified name as the listener. |
プロパティ
Attributes |
アプリケーション構成ファイルに定義されているトレース リスナーのカスタム属性を取得します。Gets the custom trace listener attributes defined in the application configuration file. |
Filter |
トレース リスナーのトレース フィルターを取得または設定します。Gets or sets the trace filter for the trace listener. |
IndentLevel |
インデント レベルを取得または設定します。Gets or sets the indent level. |
IndentSize |
1 つのインデントに含まれるスペースの数を取得または設定します。Gets or sets the number of spaces in an indent. |
IsThreadSafe |
トレース リスナーがスレッド セーフかどうかを示す値を取得します。Gets a value indicating whether the trace listener is thread safe. |
Name |
この TraceListener の名前を取得または設定します。Gets or sets a name for this TraceListener. |
NeedIndent |
出力にインデントを設定するかどうかを示す値を取得または設定します。Gets or sets a value indicating whether to indent the output. |
TraceOutputOptions |
トレース出力オプションを取得または設定します。Gets or sets the trace output options. |
メソッド
Close() |
派生クラスでオーバーライドされた場合、出力ストリームを終了して、トレース出力またはデバッグ出力を受信しないようにします。When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output. |
CreateObjRef(Type) |
リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (継承元 MarshalByRefObject) |
Dispose() |
TraceListener によって使用されているすべてのリソースを解放します。Releases all resources used by the TraceListener. |
Dispose(Boolean) |
TraceListener によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。Releases the unmanaged resources used by the TraceListener and optionally releases the managed resources. |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object. (継承元 Object) |
Fail(String) |
TraceListener クラスを実装した場合、作成したリスナーにエラー メッセージを出力します。Emits an error message to the listener you create when you implement the TraceListener class. |
Fail(String, String) |
TraceListener クラスを実装した場合、作成したリスナーにエラー メッセージと詳細エラー メッセージを出力します。Emits an error message and a detailed error message to the listener you create when you implement the TraceListener class. |
Flush() |
派生クラスでオーバーライドされた場合、出力バッファーをフラッシュします。When overridden in a derived class, flushes the output buffer. |
GetHashCode() |
既定のハッシュ関数として機能します。Serves as the default hash function. (継承元 Object) |
GetLifetimeService() |
互換性のために残されています。
対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。Retrieves the current lifetime service object that controls the lifetime policy for this instance. (継承元 MarshalByRefObject) |
GetSupportedAttributes() |
トレース リスナーによってサポートされるカスタム属性を取得します。Gets the custom attributes supported by the trace listener. |
GetType() |
現在のインスタンスの Type を取得します。Gets the Type of the current instance. (継承元 Object) |
InitializeLifetimeService() |
互換性のために残されています。
このインスタンスの有効期間ポリシーを制御する有効期間サービス オブジェクトを取得します。Obtains a lifetime service object to control the lifetime policy for this instance. (継承元 MarshalByRefObject) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object. (継承元 Object) |
MemberwiseClone(Boolean) |
現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。Creates a shallow copy of the current MarshalByRefObject object. (継承元 MarshalByRefObject) |
ToString() |
現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object. (継承元 Object) |
TraceData(TraceEventCache, String, TraceEventType, Int32, Object) |
トレース情報、データ オブジェクト、およびイベント情報をリスナー固有の出力に書き込みます。Writes trace information, a data object and event information to the listener specific output. |
TraceData(TraceEventCache, String, TraceEventType, Int32, Object[]) |
トレース情報、データ オブジェクトの配列、およびイベント情報をリスナー固有の出力に書き込みます。Writes trace information, an array of data objects and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32) |
トレース情報およびイベント情報をリスナー固有の出力に書き込みます。Writes trace and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) |
トレース情報、メッセージ、およびイベント情報をリスナー固有の出力に書き込みます。Writes trace information, a message, and event information to the listener specific output. |
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) |
トレース情報、オブジェクトの書式付き配列、およびイベント情報をリスナー固有の出力に書き込みます。Writes trace information, a formatted array of objects and event information to the listener specific output. |
TraceTransfer(TraceEventCache, String, Int32, String, Guid) |
トレース情報、メッセージ、関連するアクティビティ ID、およびイベント情報をリスナー固有の出力に書き込みます。Writes trace information, a message, a related activity identity and event information to the listener specific output. |
Write(Object) |
オブジェクトの ToString() メソッドの値を、TraceListener クラスを実装した時に作成したリスナーに書き込みます。Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class. |
Write(Object, String) |
カテゴリ名と、オブジェクトの ToString() メソッドの値を、TraceListener クラスを実装するときに作成したリスナーに書き込みます。Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class. |
Write(String) |
派生クラスでオーバーライドした場合、指定したメッセージを派生クラスで作成したリスナーに書き込みます。When overridden in a derived class, writes the specified message to the listener you create in the derived class. |
Write(String, String) |
TraceListener クラスを実装した時に作成したリスナーにカテゴリ名とメッセージを書き込みます。Writes a category name and a message to the listener you create when you implement the TraceListener class. |
WriteIndent() |
このクラスの実装時に作成したリスナーにインデントを書き込み、NeedIndent プロパティを |
WriteLine(Object) |
TraceListener クラスの実装時に作成したリスナーにオブジェクトの ToString() メソッドの値と行終端記号を書き込みます。Writes the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine(Object, String) |
TraceListener クラスの実装時に作成したリスナーにカテゴリ名、オブジェクトの ToString() メソッドの値、および行終端記号を書き込みます。Writes a category name and the value of the object's ToString() method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine(String) |
派生クラスでオーバーライドした場合、派生クラスで作成したリスナーにメッセージと行終端記号を書き込みます。When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator. |
WriteLine(String, String) |
TraceListener クラスの実装時に作成したリスナーにカテゴリ名、メッセージ、および行終端記号を書き込みます。Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator. |
適用対象
スレッド セーフ
この型はスレッド セーフです。This type is thread safe.