|
Application-level Trace Logging
In addition to the Page-level Trace funtionality, 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 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 run its page-level trace statements to be output in 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:
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 DetailsAfter 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:
Section Summary
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||