TraceListener.TraceOutputOptions 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定追蹤輸出選項。
public:
property System::Diagnostics::TraceOptions TraceOutputOptions { System::Diagnostics::TraceOptions get(); void set(System::Diagnostics::TraceOptions value); };
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }
[System.Runtime.InteropServices.ComVisible(false)]
public System.Diagnostics.TraceOptions TraceOutputOptions { get; set; }
member this.TraceOutputOptions : System.Diagnostics.TraceOptions with get, set
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.TraceOutputOptions : System.Diagnostics.TraceOptions with get, set
Public Property TraceOutputOptions As TraceOptions
列舉值的位元組合。 預設為 None。
- 屬性
設定作業失敗,因為值無效。
下列範例顯示主控台追蹤接聽程式的屬性設定 TraceOutputOptions 。 主控台追蹤接聽程式是在追蹤來源的 屬性中 Listeners 列舉的其中一個接聽程式。 此程式代碼範例是針對 類別提供的較大範例的 TraceSource 一部分。
ts.Listeners["console"].TraceOutputOptions |= TraceOptions.Callstack;
ts.Listeners("console").TraceOutputOptions = ts.Listeners("console").TraceOutputOptions Or TraceOptions.Callstack
屬性 TraceOutputOptions 會決定追蹤輸出的選擇性內容。 屬性可以在組態檔中設定,或在執行期間以程序設計方式設定,以特別包含程式代碼區段的其他數據。 例如,您可以設定 TraceOutputOptions 主控台追蹤接聽程式的 屬性, TraceOptions.Callstack 將呼叫堆疊資訊新增至追蹤輸出。
TraceOptions下列類別和方法不會使用列舉:
類別 EventLogTraceListener ,因為它可能會導致大量數據寫入記錄檔。
Write
WriteLine
、 DefaultTraceListener和類別的 ConsoleTraceListener和 TextWriterTraceListener 方法。Write在衍生類別中未覆寫類別時,類別的 TraceListener 和 WriteLine 方法。
產品 | 版本 |
---|---|
.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 |