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指令或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 类的新实例。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()

返回一个表示当前对象的 string。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.

适用于

另请参阅