TraceContext TraceContext TraceContext TraceContext Class

定義

擷取並提出關於 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
繼承
TraceContextTraceContextTraceContextTraceContext

備註

您可以使用這個類別, 將訊息附加到特定的追蹤分類。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指示詞或IsEnabled屬性中的屬性true設定為。To 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(HttpContext) TraceContext(HttpContext) TraceContext(HttpContext)

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

屬性

IsEnabled IsEnabled IsEnabled IsEnabled

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

TraceMode TraceMode TraceMode TraceMode

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

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)
Warn(String) Warn(String) Warn(String) Warn(String)

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

Warn(String, String) Warn(String, String) Warn(String, String) 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) Warn(String, String, Exception) Warn(String, String, Exception) 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) Write(String) Write(String) Write(String)

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

Write(String, String) Write(String, String) Write(String, String) Write(String, String)

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

Write(String, String, Exception) Write(String, String, Exception) Write(String, String, Exception) Write(String, String, Exception)

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

事件

TraceFinished TraceFinished TraceFinished TraceFinished

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

適用於

另請參閱