13.2. Uncovering Application-Wide Problems

Problem

You want to find the sources of problems at any point in an application, but you don’t want to have to change every page to do so, nor do you want to disrupt the output of your application pages.

Solution

Enable application-level tracing in the application web.config file and view the AXD application trace log for your application.

  1. Locate the web.config file in the root directory of your application (or create one if it does not exist).

  2. Enable application-level tracing by adding a <trace> element to the <system.web> section of web.config and setting its enabled attribute to "true":

    	<configuration>
    		<system.web>
    			<trace enabled="true" />
    
    		</system.web>
    	</configuration>
  3. View the application trace log by browsing to the trace.axd page from the application root, like this:

    http://localhost/<yourapplicationname>/trace.axd

Figure 13-2 shows some sample trace log output.

Application-level tracing output (trace.axd)

Figure 13-2. Application-level tracing output (trace.axd)

Discussion

By adding a <trace> element to web.config and setting its enabled attribute to "true", you can activate application-level tracing.

	<trace enabled="true" />

What happens is that ASP.NET collects trace information for each HTTP request to the application and directs it to the application trace log. You can view the application trace log in the trace viewer. To view the trace viewer, request trace.axd from the root ...

Get ASP.NET 2.0 Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.