Application-level Trace Logging
In addition to the Page-level Trace functionality, ASP.NET provides a way to enable trace output for an entire application. Enabling Trace
at the application level has the effect of enabling Page-level Trace for every page within that application (provided there is no page-level directive to explicitly disable trace). When application-level
tracing is enabled, the ASP.NET runtime also collects several additional statistics, such as the state of the control hierarchy, the contents of
session and application state, the form and querystring input values, and other characteristics of a request's execution. These statistics
are collected for a specified number of requests as determined by the application's configuration file. To enable tracing for an
application, place the following in the application's web.config file at the application root directory:
<configuration>
<system.web>
<trace enabled="true"/>
</system.web>
</configuration>
Using the above configuration, each page in the application will have its page-level trace statements output to the client browser. To access the additional page
statistics, request a specially-mapped "trace.axd" URL from the application root. For example, if the URL to your application
is http://localhost/myapplication, you would request the URL
http://localhost/myapplication/trace.axd to access the trace statistics for that application.

By default, trace information will be collected for up to 10 requests (you can use the "clear current trace" link to reset the request
counter). The trace section of the configuration file also supports an attribute for controlling whether trace statements are output
to the client browser, or whether they are only available from trace.axd. The attributes supported in the trace configuration section
are listed in the table below:
| Value | Description |
| enabled | Set to true | false, indicates whether Tracing is enabled for the application (default is false) |
| pageOutput | Set to true | false, indicates whether trace information should be rendered at the end of each page - or only accessible via the trace.axd utility (default is false) |
| requestLimit | Number of trace requests to store on the server (default is 10) |
| traceMode | Set to SortByTime | SortByCategory, indicates the display order for Trace messages (default is SortByTime) |
| localOnly | Set to true | false, indicates whether Tracing is enabled for localhost users or for all users (default is true) |
For example, the following configuration collects trace information for up to 40 requests, and prevents
trace statements from being output to the requesting browser (provided there is no page-level directive
to explicitly enable trace). The messages are displayed in order of category:
<configuration>
<system.web>
<trace
enabled="true"
traceMode="SortByCategory"
requestLimit="40"
pageOutput="false"
localOnly="true"
/>
</system.web>
</configuration>
Application Trace Request Details
After making a series of requests to the application, accessing trace.axd will list those requests in time-order. You can drill-down into
the details for each request by selecting the "View Details" link.
The trace application presents the following detailed information for
each request:
|
Request Detail
|
| Value | Description |
| Session Id | The Session Id for this request |
| Time of Request | The time the request was made |
| Status Code | The returned status code for this request |
| Request Type | GET | POST |
| Request Encoding | Encoding for the request |
| Response Encoding | Encoding for the response |
|
Trace Information
|
| Value | Description |
| Category | The category for a Trace statement written to the TraceContext |
| Message | The message string for this Trace statement |
| From First (s) | Time in seconds from the first Trace statement |
| From Last (s) | Time in seconds from the previous Trace statement |
|
Control Hierarchy
|
| Value | Description |
| Control ID | The ID for the control |
| Type | The fully qualified type of the control |
| Render Size | The size of the control's rendering in bytes including children |
| ViewState Size | The size of the control's viewstate in bytes excluding children |
|
Session State
|
| Value | Description |
| Key | The key for an object in Session State |
| Type | The fully qualified type of the object |
| Value | The value of the object |
|
Application State
|
| Value | Description |
| Key | The key for an object in Application State |
| Type | The fully qualified type of the object |
| Value | The value of the object |
|
Cookies Collection
|
| Value | Description |
| Name | The name of the cookie |
| Value | The value of the cookie, or sub-keys/values if multi-valued |
| Size | The size of the cookie rendering in Bytes |
|
Headers Collection
|
| Value | Description |
| Name | The name of the header |
| Value | The value of the header |
|
Form Collection
|
| Value | Description |
| Name | The name of the form variable |
| Value | The value of the form variable |
|
QueryString Collection
|
| Value | Description |
| Name | The name of the querystring variable |
| Value | The value of the querystring variable |
|
Server Variables
|
| Value | Description |
| Name | The name for the server variable |
| Value | The value of the server variable |
|