共用方式為


FileLogTraceListener.TraceEvent 方法

定義

將追蹤與事件資訊寫入輸出檔案或串流。

多載

名稱 Description
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

會將追蹤資訊、訊息及事件資訊寫入輸出檔案或串流。

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

將追蹤資訊、格式化的物件陣列及事件資訊寫入輸出檔案或串流。

備註

TraceEvent 方法並非設計用來由應用程式程式碼呼叫。 這些方法由 、 TraceTraceSource 類別的成員Debug呼叫,將追蹤資料寫入輸出。

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

來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb

會將追蹤資訊、訊息及事件資訊寫入輸出檔案或串流。

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ message);
public override void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string message);
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string -> unit
Public Overrides 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

一則訊息要寫。

備註

此方法:

  1. 格式化輸出所需的資料與上下文資訊。

  2. 必要時建立新的日誌檔。

  3. 將資訊寫入日誌檔案。

欲了解更多建立新日誌檔案的資訊,請參見 FullLogFileName

此表列出輸出欄位依出現順序排列。 欄位由該 Delimiter 性質指定的字串界定,後面接著一個線終止符。

欄位 輸出條件 說明
source 總是。 name 的值。
severity 總是。 eventType列舉值名稱。
id 總是。 id字串表示。
message 總是。 message 的值。
callStack Callstack 該物件設定了旗標 TraceOutputOptions eventCache性質。Callstack
CorrelationID LogicalOperationStack 該物件設定了旗標 TraceOutputOptions eventCache性質。ThreadId
DateTime DateTime 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示DateTime。 不變文化用於字串轉換。
ProcessID ProcessId 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示ProcessId。 不變文化用於字串轉換。
ThreadID ThreadId 該物件設定了旗標 TraceOutputOptions eventCache性質。ThreadId
Timestamp Timestamp 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示Timestamp。 不變文化用於字串轉換。
HostName 當性質 IncludeHostNameTrue時。 計算機的名稱。

另請參閱

適用於

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

來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb
來源:
FileLogTraceListener.vb

將追蹤資訊、格式化的物件陣列及事件資訊寫入輸出檔案或串流。

public:
 override void TraceEvent(System::Diagnostics::TraceEventCache ^ eventCache, System::String ^ source, System::Diagnostics::TraceEventType eventType, int id, System::String ^ format, ... cli::array <System::Object ^> ^ args);
public override void TraceEvent(System.Diagnostics.TraceEventCache eventCache, string source, System.Diagnostics.TraceEventType eventType, int id, string format, params object[] args);
override this.TraceEvent : System.Diagnostics.TraceEventCache * string * System.Diagnostics.TraceEventType * int * string * obj[] -> unit
Public Overrides 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 包含零個或多個可格式化物件的陣列。

備註

此方法:

  1. 格式化輸出所需的資料與上下文資訊。

  2. 必要時建立新的日誌檔。

  3. 將資訊寫入日誌檔案。

欲了解更多建立新日誌檔案的資訊,請參見 FullLogFileName

此表列出輸出欄位依出現順序排列。 欄位由該 Delimiter 性質指定的字串界定,後面接著一個線條終止符。

欄位 輸出條件 說明
source 永遠 name 的值。
severity 永遠 eventType列舉值名稱。
id 永遠 id字串表示。
message 永遠 資料格式 args 化為字 format 串,並使用不變文化進行字串轉換。
callStack Callstack 該物件設定了旗標 TraceOutputOptions eventCache性質。Callstack
CorrelationID LogicalOperationStack 該物件設定了旗標 TraceOutputOptions eventCache性質。ThreadId
DateTime DateTime 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示DateTime。 不變文化用於字串轉換。
ProcessID ProcessId 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示ProcessId。 不變文化用於字串轉換。
ThreadID ThreadId 該物件設定了旗標 TraceOutputOptions eventCache性質。ThreadId
Timestamp Timestamp 該物件設定了旗標 TraceOutputOptions 的屬性eventCache的串表示Timestamp。 不變文化用於字串轉換。
HostName 當性質 IncludeHostNameTrue時。 計算機的名稱。

另請參閱

適用於