ASP.NET Applications > ASP.NET Optimization > ASP.NET Trace Functionality > Application-level Tracing > Enabling Application-level Tracing
ASP.NET Web Applications ASP.NET Trace Functionality
You can enable tracing for an entire application in that application’s configuration system the Web.config
file in the application’s root directory. When you do this, ASP.NET collects internal trace information for each request to the application, up to the maximum number of requests you specify. The default number of requests is ten.
When you enable global tracing, you also enable page-level tracing for all the pages in the application, unless you explicitly disable tracing in a page using the @ Page directive with a Trace = "false" attribute and value. Any TraceContext.Write or TraceContext.Warn statements that you have included in a page’s code will be stored and returned to the application-level trace viewer.
If you want these statements and the rest of the trace information to appear appended to the end of the page that they are associated with, set the PageOutput attribute in the tracing configuration section of the Web.config
file to true. If you want tracing information to not display on your application’s pages, set this attribute to false. If you enable application-level tracing but do not want trace information displayed for some pages of the application but not others, set the Trace attribute to false for those pages you do not want trace information displayed in using the @ Page directive.
For more information about configuring your ASP.NET application, see ASP.NET Configuration.
The following are all the attributes you can use to modify the behavior of application-level tracing.
Property |
Description |
enabled |
true if tracing is enabled for the application; otherwise false. The default is false. |
pageOutput |
true if trace information should be displayed both on an application’s pages and in the .axd trace utility; otherwise false. The default is false.
NOTE: Pages that have tracing enabled on them are not affected by this setting.
|
requestLimit |
Number of trace requests to store on the server. The default is 10. |
traceMode |
Indicates whether trace information should be displayed in the order it was processed, SortByTime, or alphabetically by user-defined category, SortByCategory. SortByTime is the default. |
localOnly |
true if the trace viewer ( trace.axd ) is only available on the host Web server; otherwise false. The 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:
<configuration>
<system.web>
<trace enabled = "true" requestLimit = "40" pageOutput = "false" />
</system.web>
</configuration>
NOTE: The ASP.NET configuration system is case-sensitive. All single word configuration sections are lowercase, while any sections or attributes that are concatenations of two words must be camel-cased. For example, requestlimit
will cause a parser error, while requestLimit
will not.
Application-level Tracing Viewing Application-level Trace Information With the Trace Viewer