FileLogTraceListener.TraceEvent 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將追蹤與事件資訊寫入輸出檔案或串流。
多載
| 名稱 | Description |
|---|---|
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String) |
會將追蹤資訊、訊息及事件資訊寫入輸出檔案或串流。 |
| TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[]) |
將追蹤資訊、格式化的物件陣列及事件資訊寫入輸出檔案或串流。 |
備註
TraceEvent 方法並非設計用來由應用程式程式碼呼叫。 這些方法由 、 Trace和 TraceSource 類別的成員Debug呼叫,將追蹤資料寫入輸出。
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)
會將追蹤資訊、訊息及事件資訊寫入輸出檔案或串流。
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
一則訊息要寫。
備註
此方法:
格式化輸出所需的資料與上下文資訊。
必要時建立新的日誌檔。
將資訊寫入日誌檔案。
欲了解更多建立新日誌檔案的資訊,請參見 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 |
當性質 IncludeHostName 為 True時。 |
計算機的名稱。 |
另請參閱
適用於
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String, Object[])
將追蹤資訊、格式化的物件陣列及事件資訊寫入輸出檔案或串流。
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 包含零個或多個可格式化物件的陣列。
備註
此方法:
格式化輸出所需的資料與上下文資訊。
必要時建立新的日誌檔。
將資訊寫入日誌檔案。
欲了解更多建立新日誌檔案的資訊,請參見 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 |
當性質 IncludeHostName 為 True時。 |
計算機的名稱。 |