# tracing in asp.net¶

in web config

Tracing can be turned on or off
1. At the application level or
2. At the page level

To enable tracing at the application level set "trace" element's "enabled" attribute to "true" in web.config. This enables tracing for all pages in the application.
<trace enabled="true"/>

To disable tracing for specific pages, set Trace="false" in the webform's "Page" directive
<%@ Page Language="C#" Trace="false" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

If tracing is enabled at the application level, the trace messages are written to a file called trace.axd. Trace.xd file can only be accessed locally. To make the trace file available to remote users set localOnly="false". Tracing displays sensitive information, that could be useful to a hacker to hack into the server. So set this attribute to "false" only when it is required.
<trace enabled="true" localOnly="false"/>

To append trace messages at the end of the page set pageOutput="true".
<trace enabled="true" pageOutput="true" localOnly="false"/>

Use RequestLimit attribute to control the number of trace requests that are stored on the server. The default is 10. After this limit is reached, the sever will stop writing to the trace file.
<trace enabled="true" pageOutput="true" requestLimit="5" localOnly="false"/>

If you want to log trace messages, even after the requestLimit has reached set mostRecent attribute to true. When this attribute is set to true, the old entries in the trace log are discarded and the new entries get added.
<trace enabled="true" mostRecent="true" requestLimit="3"/>