You can enable tracing for the entire application in the web. config file of the application root directory. By default, application-level tracing can only be viewed on a local web server computer. Required
Set localonly to false in the web. config file to view application-level tracing information on a remote computer.
To disable remote tracing, set the localonly attribute to true in the web. config file. The following example shows an Application Tracking configuration, which collects up to 40
Request tracing information, and allows browsers on computers other than the original server to display the tracing viewer.
<Configuration>
<System. Web>
<Trace enabled = "true" requestlimit = "40" localonly = "false"/>
</System. Web>
</Configuration>
When you enable application tracing, ASP. NET collects tracing information for each application request until the maximum number of requests reaches your specified value. The default number of requests is 10. When the trail is viewed
When the application reaches its request limit, the application stops storing tracing requests.
Note: When tracing of the entire application is enabled in the web. config file, tracing information is collected and processed for each page of the application. To disable tracing for specific pages in an application,
Set the trace attribute to false in the @ page command on this page. Will store any tracecontext. Write or tracecontext. Warn statements that you include in the page code, and
And they are only returned to the trace viewer.
If you want to append the trace information to the end of the page associated with it, set the pageoutput attribute to true in the tracking configuration section of the web. config file. If you want to trace information, only
In the trace viewer, set this attribute to false. If you enable application-level tracing but do not want to display tracing information for certain pages of the application, you do not want to use the @ page command.
Set the trace attribute of the page to false.
The following are all attributes that can be used to modify application-level tracking behavior.
Attribute description
Enabled: true if application-level tracing is enabled; otherwise, false. The default value is false.
Pageoutput: true if the trace information is displayed on both the application page and the. axd trace utility; otherwise, false. The default value is false.
Note that the page on which the trail is enabled is not affected by this setting.
The number of Trace Requests stored on the requestlimit server. The default value is 10.
Tracemode indicates whether trace information is displayed in sortbytime or in the alphabetical order of user-defined categories. The default value is
Sortbytime.
Localonly: true if the trace Viewer (trace. axd) is only available on the Web server of the host; otherwise, false. The default value is true.
Enable application-level Tracing
If you have not performed this operation, create a text file, name it web. config, and save it to the root directory of the application.
Add the start and end tags of the <system. Web> element between the start and end tags of the <configuration> element.
Add the <trace> element between <system. Web> element tags (which is self-terminated ).
In the <trace> element, declare the enabled attribute and set it to true.
Declare other optional attributes and modify the tracking behavior of the application as needed.
For example, the following application tracking configuration collects tracing information for up to 40 requests and allows browsers on computers other than the original server to display the tracking viewer.
<Configuration>
<System. Web>
<Trace enabled = "true" requestlimit = "40" localonly = "false"/>
</System. Web>
</Configuration>
Note that the ASP. NET Configuration System is case sensitive. The configuration section of each word is in lower case, and the section or attribute of two words in series must be in the case of camel. For example,
Requestlimit is a valid attribute name, while requestlimit causes analyzer errors.
View trace information in the tracking Viewer
Once application-level tracing is enabled, when each page in the application is requested, it executes any trace statements contained. By requesting trace. axd in the application root directory, you can
View these statements and other trace information in the trace viewer.
Note: When application-level tracing is enabled, you can set the pageoutput attribute to true in the web. config file to view the tracing statement and its
His information.
The trail Viewer allows you to select a specific request from the application request page. The following screen displays a trace viewer that has seven
Application requests.
Tracking Viewer
If the tracing application is enabled with multiple requests arriving, the tracing viewer lists the requests in the order they are processed. The information on the start page of the tracing viewer includes: request time, request
File, the Request status code, the HTTP predicate associated with the request, and the "View Details" link that allows you to view more detailed information about the request. The number of displayed requests will not
Exceeds the requestlimit setting you specified in the web. config file.
View detailed tracing information for a specific request
Go to the trail viewer associated with your application.
For example, if the application URL is http: // localhost/myapplication, locate http: // localhost/myapplication/trace. axd to view
Trace statistics.
Select the "View Details" link of the request to be studied.
After "View Details" is selected, you can view the same information as the page to which the trail is enabled.
In some cases, you may want to remove all requests stored in the trail viewer. You may want to track the changes made to the files in the application, or you just want to view the requests with the current display.
Information of files other than the associated files.
Clear requests from the trail Viewer
Locate the trail viewer associated with the application.
Select the "clear current trail" link to remove all requests stored in the trail Viewer application.
Note that the trail viewer only tracks requests after the records are cleared. You cannot view the requests made after the request limit is reached and the requests made before the deletion record.