EventLogTraceListener.TraceEvent 方法

定義

將事件追蹤資訊寫入事件記錄檔。

多載

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

寫入追蹤資訊、訊息,以及事件資訊至事件記錄檔。

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])

寫入追蹤資訊,格式化的物件陣列,及事件資訊至事件記錄檔。

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

來源:
EventLogTraceListener.cs
來源:
EventLogTraceListener.cs
來源:
EventLogTraceListener.cs

寫入追蹤資訊、訊息,以及事件資訊至事件記錄檔。

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType severity, int id, System::String ^ message);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string message);
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, severity As TraceEventType, id As Integer, message As String)

參數

eventCache
TraceEventCache

包含目前處理序 ID、執行緒 ID 和堆疊追蹤資訊的物件。

source
String

用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱。

severity
TraceEventType

其中一個列舉值,指定引發追蹤的事件型別。

id
Int32

事件的數值識別項。 sourceid 的組合,會唯一識別事件。

message
String

追蹤訊息。

屬性

例外狀況

source 未指定。

-或-

記錄項目字串超過 32,766 個字元。

備註

重要

方法 TraceEvent 並非由應用程式程式代碼呼叫。 這些方法是由、 TraceTraceSource 類別的 方法來Debug呼叫,以寫入追蹤數據。

方法 TraceEvent 旨在追蹤可由工具自動處理的事件。 例如,監視工具可以在特定來源追蹤特定事件時通知系統管理員。

eventCachesource 參數可用來判斷是否應該追蹤事件。 id 是用來建立 EventInstance 物件, TraceEventType 而會等於 EventLogEntryType 屬性的 EntryType 。 會EventInstance使用 WriteEvent 方法將數據寫入事件記錄檔message

注意

參數的 id 最大值為 65,535。 id如果指定的值大於 65,535,則會使用最大值。

適用於

TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])

來源:
EventLogTraceListener.cs
來源:
EventLogTraceListener.cs
來源:
EventLogTraceListener.cs

寫入追蹤資訊,格式化的物件陣列,及事件資訊至事件記錄檔。

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType severity, int id, System::String ^ format, ... cli::array <System::Object ^> ^ args);
[System.Runtime.InteropServices.ComVisible(false)]
public override void TraceEvent (System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType severity, int id, string format, params object[] args);
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
Public Overrides Sub TraceEvent (eventCache As TraceEventCache, source As String, severity As TraceEventType, id As Integer, format As String, ParamArray args As Object())

參數

eventCache
TraceEventCache

包含目前處理序 ID、執行緒 ID 和堆疊追蹤資訊的物件。

source
String

用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱。

severity
TraceEventType

其中一個列舉值,指定引發追蹤的事件型別。

id
Int32

事件的數值識別項。 sourceid 的組合,會唯一識別事件。

format
String

包含零或多個格式項目的格式字串,這些項目與 args 陣列中的物件相對應。

args
Object[]

object 陣列,含有零或多個要格式化的物件。

屬性

例外狀況

source 未指定。

-或-

記錄項目字串超過 32,766 個字元。

備註

重要

方法 TraceEvent 並非由應用程式程式代碼呼叫。 這些方法是由、 TraceTraceSource 類別的 方法來Debug呼叫,以寫入追蹤數據。

方法 TraceEvent 旨在追蹤可由工具自動處理的事件。 例如,監視工具可以在特定來源追蹤特定事件時通知系統管理員。

eventCachesource 參數可用來判斷是否應該追蹤事件。 id 是用來建立 EventInstance 物件, TraceEventType 而會等於 EventLogEntryType 屬性的 EntryType 。 會 EventInstance 使用 WriteEvent 方法,搭配從 formatargs 參數取得的訊息,寫入事件記錄檔。 物件 args 陣列會使用 Format 方法轉換成字串,傳遞 format 字串和 args 數位,將字串格式化為事件記錄檔的訊息。

注意

參數的 id 最大值為 65,535。 id如果指定的值大於 65,535,則會使用最大值。

適用於