In addition to the exposing a generalized trace facility to developers, the ASP+ runtime can also collect helpful request information globally for an application. Collecting this additional data must be explicitly enabled for the application through the configuration system. Unlike custom user-defined Trace statements, these internal trace categories are not exposed in the client browser, but are displayed by the trace viewer application instead. The trace viewer displays trace information for a series of requests to the application, so metrics for each request must be stored in memory while tracing is enabled. This is made possible by inserting an IHttpModule-derived class, TraceModule, that participates in the HTTP Pipeline execution of each request to the application.
Enabling Global Trace through Configuration
Global tracing is enabled through the configuration system at the application level only, by the presence of a <tracing> configuration section with the enabled property set to true. Internal trace information is collected for each request to the application, up to a specific number of requests (the default is 10).
Enabling global tracing has the side effect of enabling page-level trace functionality for the entire application, overriding any settings in page-level directives that explicitly disable Trace. That is, any user-defined Trace.Write or Trace.Warn statements in application code will be executed and stored for viewing in the Trace Viewer. Optionally, the user can define a PageOutput property to force Trace statements to also be rendered in the browser client, as they would if tracing were enabled in a page-level directive. Pages for which tracing is already enabled by a page-level directive are not affected by the absence of this property.
For example:
<configuration> <configsections> <add name="trace" type="System.Web.Config.TraceConfigHandler"> </configsections> <tracing enabled="false" requestlimit="15" pageoutput="true" /> </configuration>
The following are configuration parameters for tracing.
Property | Description |
Enabled | true if tracing is enabled for the application; otherwise false. The default is false. |
PageOutput | Indicates whether trace information should be rendered at the end of each page – or only accessible via the trace utility. |
RequestLimit | Number of trace requests to store on the server. The default is 10. |
See Also