Tracing for the entire application can be enabled in the Web.config file in the application root directory. By default, application-level traces can only be viewed on the local web server computer. You must
set localOnly to false in the Web.config file so that application-level tracing information is visible from the remote computer.
To disable remote tracing, set the localOnly property to true in the Web.config file. The following example shows an application tracing configuration that collects
trace information for up to 40 requests and allows browsers on machines other than the origin server to display the trace viewer.
<configuration>
<system.web>
<trace enabled="true" requestLimit="40" localOnly="false"/>
</system.web>
</configuration>
When you enable tracing for an application, ASP.NET collects tracing information for each request to the application until the maximum number of requests that you specify is reached. The default number of requests is 10. When the trace viewer
reaches its request limit, the application stops storing trace requests.
Note When you enable tracing for an entire application in the Web.config file, tracing information is collected and processed for each page in the application. To disable tracing for a specific page in your application,
set the Trace property to false in the page's @Page directive. Any TraceContext.Write or TraceContext.Warn statements that you include in the page code are stored
and
are only returned to the Trace Viewer.
If you want tracing information to be appended to the end of the page with which it is associated, set the pageOutput property to true in the tracing configuration section of the Web.config file. If you want trace information to be displayed only in
the trace viewer, set this property to false. If you enable application-level tracing but do not want trace information to be displayed for certain pages of your application, use the @Page directive to
set the Trace property to false for the pages for which you do not want trace information to be displayed.
Below are all properties that can be used to modify application-level tracing behavior.
Property description
enabled true if application-level tracing is enabled; false otherwise. The default value is false.
pageOutput true if tracing information is displayed on both the application page and the .axd tracing utility; otherwise, false. The default value is false.
Note Pages that have tracking enabled are not affected by this setting.
requestLimit Number of tracking requests stored on the server. The default value is 10.
traceMode indicates whether trace information is displayed in the order in which they were processed (SortByTime) or in alphabetical order by user-defined categories (SortByCategory). The default value is
SortByTime.
localOnly true if the trace viewer (Trace.axd) is available only on the host Web server; otherwise, false. The default value is true.
Enable application-level tracing
If you have not already done so, create a text file, name it Web.config, and save it to the root directory of your application.
Between the opening and closing tags of the <configuration> element, add the opening and closing tags of the <system.web> element.
Between the <system.web> element tags, add a <trace> element (it is self-closing).
In the <trace> element, declare the enabled attribute and set it to true.
Declare other optional properties to modify your application's tracking behavior to suit your needs.
For example, the following application tracing configuration collects trace information for up to 40 requests and allows browsers on machines other than the origin server to display the trace viewer.
<configuration>
<system.web>
<trace enabled="true" requestLimit="40" localOnly="false"/>
</system.web>
</configuration>
Note that the ASP.NET configuration system is case-sensitive. All single-word configuration sections are lowercase, while two-word concatenated sections or attributes must be in Camel case. For example,
requestLimit is a valid property name, but requestlimit results in a parser error.
View trace information with Trace Viewer Once application-level tracing is enabled, when each page in the application is requested, it will execute any trace statements it contains.
can be viewed in the
trace
viewer by requesting Trace.axd in the application root directory .Note When application-level tracing is enabled, you can view trace statements and
other
information in any page of the application by setting the pageOutput property to true in the Web.config file .
The trace viewer allows you to select specific requests among the pages that have been requested from the application. The screenshot below shows a trace viewer that has 7 requests to its
application
after tracing is enabled .Trace Viewer
If multiple requests arrive for a tracing-enabled application, the Trace Viewer lists them in the order in which they were processed. Information on the trace viewer start page includes: the time of the request,
the file requested, the request's status code, the HTTP verb associated with the request, and a View Details link that allows you to view more detailed information about the request. The number of requests displayed will not
exceed the requestLimit setting you specify in the Web.config file.
To view trace details for a specific request,
navigate to the trace viewer associated with your application.
For example, if your application's URL is http://localhost/myapplication , navigate to http://localhost/myapplication/trace.axd to view the application's
trace
statistics.Select the View Details link for the request you want to research.
When you select View Details, you'll see the same information appended to a tracking-enabled page.
In some cases, you may want to remove all requests stored in the trace viewer. Maybe you want to track changes made to files in your application, or maybe you just want to see
information about a file other than the one associated with the currently displayed request.
TheClear from Trace Viewer request
targets the trace viewer associated with the application.
Select the Clear Current Trace link to remove all requests stored in the Trace Viewer application.
Note The trace viewer only traces requests made after the record has been cleared. Requests made after the request limit was reached and before the record was cleared cannot be viewed.