TraceListener.TraceEvent 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將追蹤與事件資訊寫入聽者專屬輸出。
多載
| 名稱 | Description |
|---|---|
| TraceEvent(TraceEventCache, String, TraceEventType, Int32) |
將追蹤與事件資訊寫入聽者專屬輸出。 |
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) |
將追蹤資訊、訊息及事件資訊寫入監聽器特定的輸出。 |
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) |
將追蹤資訊、格式化的物件陣列及事件資訊寫入監聽器專屬輸出。 |
TraceEvent(TraceEventCache, String, TraceEventType, Int32)
將追蹤與事件資訊寫入聽者專屬輸出。
public:
virtual void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id);
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int -> unit
Public Overridable Sub TraceEvent (eventCache As TraceEventCache, source As String, eventType As TraceEventType, id As Integer)
參數
- eventCache
- TraceEventCache
一個 TraceEventCache 包含目前程序 ID、執行緒 ID 及堆疊追蹤資訊的物件。
- source
- String
用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱。
- eventType
- TraceEventType
其中一個 TraceEventType 值指定了導致追蹤的事件類型。
- id
- Int32
事件的數字識別碼。
- 屬性
備註
Important
此方法並非設計用來直接由應用程式代碼呼叫,而是由 、 Debug及Trace類別的成員TraceSource來寫入追蹤資料輸出。
預設實作會將 和 sourceeventType 參數的id值寫入為標頭。
eventCache資料以頁腳形式寫入,輸出資料的性質取決於屬性TraceOutputOptions的值。
另請參閱
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- EventLogTraceListener
- TextWriterTraceListener
- Debug
- Trace
適用於
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)
將追蹤資訊、訊息及事件資訊寫入監聽器特定的輸出。
public:
virtual void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ message);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string? message);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
Public Overridable Sub TraceEvent (eventCache As TraceEventCache, source As String, eventType As TraceEventType, id As Integer, message As String)
參數
- eventCache
- TraceEventCache
一個 TraceEventCache 包含目前程序 ID、執行緒 ID 及堆疊追蹤資訊的物件。
- source
- String
用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱。
- eventType
- TraceEventType
其中一個 TraceEventType 值指定了導致追蹤的事件類型。
- id
- Int32
事件的數字識別碼。
- message
- String
要寫入的訊息。
- 屬性
備註
Important
此方法並非設計用來直接由應用程式代碼呼叫,而是由 、 Debug及Trace類別的成員TraceSource來寫入追蹤資料輸出。
預設實作會將 與 sourceeventType參數的值id寫入為標頭,接著是message資料。
eventCache資料以頁腳形式寫入,輸出資料的性質取決於屬性TraceOutputOptions的值。
另請參閱
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- EventLogTraceListener
- TextWriterTraceListener
- Debug
- Trace
適用於
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])
將追蹤資訊、格式化的物件陣列及事件資訊寫入監聽器專屬輸出。
public:
virtual void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ format, ... cli::array <System::Object ^> ^ args);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string? format, params object?[]? args);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache? eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object?[]? args);
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
Public Overridable Sub TraceEvent (eventCache As TraceEventCache, source As String, eventType As TraceEventType, id As Integer, format As String, ParamArray args As Object())
參數
- eventCache
- TraceEventCache
一個 TraceEventCache 包含目前程序 ID、執行緒 ID 及堆疊追蹤資訊的物件。
- source
- String
用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱。
- eventType
- TraceEventType
其中一個 TraceEventType 值指定了導致追蹤的事件類型。
- id
- Int32
事件的數字識別碼。
- format
- String
一個格式字串,包含零個或多個格式項目,對應陣列中的 args 物件。
- args
- Object[]
一個 object 包含零個或多個可格式化物件的陣列。
- 屬性
備註
Important
此方法並非設計用來直接由應用程式代碼呼叫,而是由 、 Debug及Trace類別的成員TraceSource來寫入追蹤資料輸出。
預設實作會將 和 sourceeventType 參數的id值寫入為標頭。
args利用該Format方法將物件陣列轉換成字串,並將字串與format陣列傳遞args,將字串格式化為追蹤中的訊息部分。
eventCache資料以頁腳形式寫入,輸出資料的性質取決於屬性TraceOutputOptions的值。
另請參閱
- TraceListener
- DefaultTraceListener
- ConsoleTraceListener
- EventLogTraceListener
- TextWriterTraceListener
- Debug
- Trace