TraceListener.TraceOutputOptions 屬性

定義

取得或設定追蹤輸出選項。

C#
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }
C#
[System.Runtime.InteropServices.ComVisible(false)]
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }

屬性值

列舉值的位元組合。 預設為 None

屬性

例外狀況

設定作業失敗,因為值無效。

範例

下列範例顯示主控台追蹤接聽程式的屬性設定 TraceOutputOptions 。 主控台追蹤接聽程式是在追蹤來源的 屬性中 Listeners 列舉的其中一個接聽程式。 此程式代碼範例是針對 類別提供的較大範例的 TraceSource 一部分。

C#
ts.Listeners["console"].TraceOutputOptions |= TraceOptions.Callstack;

備註

屬性 TraceOutputOptions 會決定追蹤輸出的選擇性內容。 屬性可以在組態檔中設定,或在執行期間以程序設計方式設定,以特別包含程式代碼區段的其他數據。 例如,您可以設定 TraceOutputOptions 主控台追蹤接聽程式的 屬性, TraceOptions.Callstack 將呼叫堆疊資訊新增至追蹤輸出。

TraceOptions下列類別和方法不會使用列舉:

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1