DelimitedListTraceListener 類別

定義

將追蹤或偵錯輸出導向文字寫入器,例如資料流寫入器,或導向資料流,例如檔案資料流。

public ref class DelimitedListTraceListener : System::Diagnostics::TextWriterTraceListener
public class DelimitedListTraceListener : System.Diagnostics.TextWriterTraceListener
type DelimitedListTraceListener = class
    inherit TextWriterTraceListener
Public Class DelimitedListTraceListener
Inherits TextWriterTraceListener
繼承
繼承
DelimitedListTraceListener

備註

追蹤輸出是使用 屬性所 Delimiter 指定的分隔符號的分隔符號的分隔文字格式。 分隔符號是用來終止一行輸出中的每個欄位。 例如,若要在Microsoft Excel 試算表中顯示追蹤輸出,您可以指定逗號 (「,」) 做為分隔符號,並在 CSV) 檔案 (建立逗號分隔值。

重要

此型別代表 IDisposable 介面。 當您完成使用型別時,您應該直接或間接處置它。 若要直接處置類型,請在 區塊中 try/catch 呼叫其 Dispose 方法。 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。

您可以在程式碼中建立 DelimitedListTraceListener 。 或者,在.NET Framework應用程式中,您可以透過應用程式組態檔啟用或停用 , DelimitedListTraceListener 然後使用 DelimitedListTraceListener 應用程式中設定的 。

注意

只會 DelimitedListTraceListener 使用名稱開頭 Trace 為 、例如 DelimitedListTraceListener.TraceEventTrace.TraceWarning 的方法,來分隔所發出的文字。 使用 Debug.WriteTextWriterTraceListener.WriteLine 方法發出的追蹤資料不會分隔。

DelimitedListTraceListener若要在.NET Framework應用程式中設定 ,請編輯對應至應用程式名稱的組態檔。 在此檔案中,您可以新增接聽程式、設定接聽程式的屬性,或移除接聽程式。 組態檔的格式應該如下列範例所示:

<configuration>  
  <system.diagnostics>  
    <trace autoflush="false" indentsize="4">  
      <listeners>  
        <add name="delimitedListener"   
          type="System.Diagnostics.DelimitedListTraceListener"   
          delimiter=","   
          initializeData="delimitedOutput.csv"   
          traceOutputOptions="ProcessId, DateTime" />  
      </listeners>  
    </trace>  
  </system.diagnostics>  
</configuration>  

注意

如果您嘗試寫入正在使用或無法使用的檔案,則檔案名會自動加上 GUID 的前置詞。

注意

接聽程式是要由 、 TraceTraceSource 類別的方法 Debug 用來寫入追蹤資訊。 除了建構函式以外,接聽程式方法不應該直接從應用程式程式碼呼叫。

建構函式

DelimitedListTraceListener(Stream)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入指定的輸出資料流。

DelimitedListTraceListener(Stream, String)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入至指定的輸出資料流,並具有指定的名稱。

DelimitedListTraceListener(String)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入至指定的檔案。

DelimitedListTraceListener(String, String)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入至指定的檔案,並具有指定的名稱。

DelimitedListTraceListener(TextWriter)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入至指定的文字寫入器。

DelimitedListTraceListener(TextWriter, String)

初始化 DelimitedListTraceListener 類別的新執行個體,可寫入至指定的文字寫入器,並具有指定的名稱。

屬性

Attributes

取得在應用程式組態檔中定義的自訂追蹤接聽程式屬性。

(繼承來源 TraceListener)
Delimiter

取得或設定已分隔清單的分隔符。

Filter

取得或設定追蹤接聽程式的追蹤篩選。

(繼承來源 TraceListener)
IndentLevel

取得或設定縮排層級。

(繼承來源 TraceListener)
IndentSize

取得或設定縮排的空格數目。

(繼承來源 TraceListener)
IsThreadSafe

取得值,指出追蹤接聽程式是否為安全執行緒。

(繼承來源 TraceListener)
Name

取得或設定這個 TraceListener 的名稱。

(繼承來源 TraceListener)
NeedIndent

取得或設定值,指出是否要縮排輸出。

(繼承來源 TraceListener)
TraceOutputOptions

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

(繼承來源 TraceListener)
Writer

取行或設定接收追蹤或偵錯之輸出的文字寫入器。

(繼承來源 TextWriterTraceListener)

方法

Close()

關閉 Writer 使其不再接收追蹤或偵錯的輸出。

(繼承來源 TextWriterTraceListener)
CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放 TraceListener 所使用的所有資源。

(繼承來源 TraceListener)
Dispose(Boolean)

處置這個 TextWriterTraceListener 物件。

(繼承來源 TextWriterTraceListener)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Fail(String)

當您實作 TraceListener 類別時,發出錯誤訊息給您建立的接聽程式。

(繼承來源 TraceListener)
Fail(String, String)

當您實做 TraceListener 類別時,發出錯誤訊息和詳細的錯誤訊息給您建立的接聽程式。

(繼承來源 TraceListener)
Flush()

清除 Writer 的輸出緩衝區。

(繼承來源 TextWriterTraceListener)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetSupportedAttributes()

傳回由分隔的追蹤接聽程式支援的自訂組態檔屬性。

GetSupportedAttributes()

取得由追蹤接聽程式支援的自訂屬性。

(繼承來源 TraceListener)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TraceData(TraceEventCache, String, TraceEventType, Int32, Object)

寫入追蹤資訊、資料物件,及事件資訊至輸出檔或資料流。

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

將追蹤資訊、資料物件的陣列及事件資訊寫入至輸出檔或資料流。

TraceEvent(TraceEventCache, String, TraceEventType, Int32)

寫入追蹤和事件資訊至特定接聽程式的輸出。

(繼承來源 TraceListener)
TraceEvent(TraceEventCache, String, TraceEventType, Int32, String)

寫入追蹤資訊、訊息,以及事件資訊至檔案或資料流。

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

寫入追蹤資訊、格式化的物件陣列,及事件資訊至輸出檔或資料流。

TraceTransfer(TraceEventCache, String, Int32, String, Guid)

寫入追蹤資訊、訊息、相關活動身分識別與事件資訊至特定接聽程式的輸出。

(繼承來源 TraceListener)
Write(Object)

將物件的 ToString() 方法的值寫入當您實作 TraceListener 類別時所建立的接聽程式。

(繼承來源 TraceListener)
Write(Object, String)

將類別名稱和物件的 ToString() 方法的值寫入當您實作 TraceListener 類別時所建立的接聽程式。

(繼承來源 TraceListener)
Write(String)

將訊息寫入這個執行個體的 Writer

(繼承來源 TextWriterTraceListener)
Write(String, String)

將分類名稱和訊息寫入當您實作 TraceListener 類別時所建立的接聽程式。

(繼承來源 TraceListener)
WriteIndent()

將縮排寫入當您實作這個類別時所建立的接聽程式,並且將 NeedIndent 屬性重設為 false

(繼承來源 TraceListener)
WriteLine(Object)

將物件的 ToString() 方法的值寫入當您實作 TraceListener 類別時所建立的接聽程式,後面跟隨著行結束字元。

(繼承來源 TraceListener)
WriteLine(Object, String)

將分類名稱和物件的 ToString() 方法的值寫入當您實作 TraceListener 類別時所建立的接聽程式,後面跟隨著行結束字元。

(繼承來源 TraceListener)
WriteLine(String)

將訊息寫入這個執行個體的 Writer,後面接著行結束字元。 預設行結束字元為後面接著換行符號 (\r\n) 的歸位字元。

(繼承來源 TextWriterTraceListener)
WriteLine(String, String)

將分類名稱和訊息寫入當您實作 TraceListener 類別時所建立的接聽程式,後面跟隨著行結束字元。

(繼承來源 TraceListener)

適用於