Tracing is a technique for recording events, such as exceptions, in an application. There have always been ways to record errors in an application—usually by opening a file and writing error messages to it—but tracing offers these significant advantages:
Standardization Building tracing into the .NET Framework ensures that programming techniques are the same across all the applications you develop with the .NET Framework.
Built-in Web support ASP.NET extends the .NET Framework tools by including information related to the performance and behavior of Web requests.
Configuration You can turn tracing on and off using settings in your application’s configuration file. You don’t have to recompile your application to enable or disable tracing.
Performance While disabled, tracing statements do not affect application performance.
To use tracing in a Web application, follow these steps:
Turn tracing on.
Write to the trace log.
Read the trace log.
The following sections provide details on these three steps.
Turning Tracing On and Off Tracing can be turned on or off for an entire Web application or for an individual page in the application:
To turn tracing on for an entire application, in the application’s Web.config file, set the element’s Enabled attribute to True.
To turn tracing on for a single page, set the DOCUMENT object’s Trace property to True in the Visual Studio .NET Properties window. This sets the @ Page directive’s Trace attribute to True in the Web form’s HTML. The element also includes a RequestLimit attribute to specify how many page requests to write to the trace log. For example, the following line from a Web.config file turns on tracing for the application and writes the first 20 requests to the Trace.axd file:
|
No responses found. Be the first to respond and make money from revenue sharing program.
|