Tracing is an activity to follow execution path and display the diagnostic information related to a specific Asp.Net web page or application that is being executed on the web server.
Tracing can be enabled at development environment as well as in the production environment.
In Asp.Net Tracing is disabled by default. Trace statements are executed and shown only when tracing is enabled. You can enabled tracing in two levels.
- Page Level Tracing
- Application Level Tracing.
You can enabled individual pages as well as you can enabled your application's Web.config file to display trace information. When you enabled it application level, it display all pages trace information unless the page explicitly disables tracing.
Page Level Tracing
We can control whether tracing is enabled or disabled for an Asp.Net page with the Trace attribute of the @ Page directive.
<%@ Page Trace="true" %>
<%@ Page Language="VB" Trace="true" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Application Level Tracing
When we enable application level tracing, trace information is gathered and processed for each page in that application. We can enable application level tracing by using the trace element in the Web.config file.
<configuration>
<system.web>
<trace enabled="true" pageOutput="true" requestLimit="50"
localOnly="false" mostRecent="true"traceMode="SortByTime" />
</system.web>
</configuration>
By default, application level tracing can be viewed only on the local Web server computer.