TraceContext 類別

定義

擷取並提出關於 Web 要求的執行詳細資料。Captures and presents execution details about a Web request. 此類別無法獲得繼承。This class cannot be inherited.

public ref class TraceContext sealed
public sealed class TraceContext
type TraceContext = class
Public NotInheritable Class TraceContext
繼承
TraceContext

備註

您可以使用這個類別,將訊息附加至特定的追蹤分類。You can use this class to append messages to specific trace categories. 例如,如果您要 Calendar 為應用程式建立類別的實例,您可能會在轉譯程式中包含追蹤訊息「開始轉譯」,並在事件處理常式程式中包含「引發 OnChange 事件」。For example, if you are creating an instance of the Calendar class for your application, you might include the trace message "Starting To Render" in a rendering procedure, and "Raising OnChange Event" in an event handler procedure.

您也可以使用 TraceContext 類別,在要求執行結束時取得一組追蹤記錄以進行自訂處理。You can also use the TraceContext class to obtain a set of trace records at the end of request execution for custom processing. 如需詳細資訊,請參閱 ASP.NET 追蹤總覽For more information, see ASP.NET Tracing Overview.

若要啟用追蹤,請將 Trace @ Page 指示詞或屬性中的屬性設定 IsEnabledtrueTo enable tracing, set the Trace attribute in the @ Page directive or the IsEnabled property to true. 啟用追蹤時,除了顯示使用者提供的追蹤內容之外,此 Page 類別也會自動包含每個要求的效能資料、控制樹狀結構資訊和狀態管理內容。When tracing is enabled, in addition to showing user-provided trace content, the Page class automatically includes performance data, control-tree structure information, and state management content for every request.

建構函式

TraceContext(HttpContext)

初始化 TraceContext 類別的新執行個體。Initializes a new instance of the TraceContext class.

屬性

IsEnabled

取得或設定值,表示是否已針對目前的 Web 要求啟用追蹤。Gets or sets a value indicating whether tracing is enabled for the current Web request.

TraceMode

取得或設定已排序的順序,追蹤訊息依此順序輸出至提出要求的瀏覽器。Gets or sets the sorted order in which trace messages should be output to a requesting browser.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
Warn(String)

將追蹤資訊寫入檢測檔。Writes a trace message to the trace log. 所有警告在記錄檔中顯示為紅色文字。All warnings appear in the log as red text.

Warn(String, String)

將追蹤資訊寫入檢測檔,包括任何使用者定義的分類和追蹤訊息。Writes trace information to the trace log, including any user-defined categories and trace messages. 所有警告在記錄檔中顯示為紅色文字。All warnings appear in the log as red text.

Warn(String, String, Exception)

將追蹤資訊寫入追蹤記錄檔,包括任何使用者定義的分類、追蹤訊息和錯誤資訊。Writes trace information to the trace log, including any user-defined categories, trace messages, and error information. 所有警告在記錄檔中顯示為紅色文字。All warnings appear in the log as red text.

Write(String)

將追蹤資訊寫入檢測檔。Writes a trace message to the trace log.

Write(String, String)

將追蹤資訊寫入檢測檔,包括訊息和任何使用者定義的分類。Writes trace information to the trace log, including a message and any user-defined categories.

Write(String, String, Exception)

將追蹤資訊寫入追蹤記錄檔,包括任何使用者定義的分類、追蹤訊息和錯誤資訊。Writes trace information to the trace log, including any user-defined categories, trace messages, and error information.

事件

TraceFinished

TraceContext 物件所引發,在收集所有要求資訊之後公開追蹤訊息。Raised by the TraceContext object to expose trace messages after all request information is gathered.

適用於

另請參閱