Smart use: Trace trace output for debugging

Source: Internet
Author: User

(i). Description
Many people in the debugging input, general use: Respone.write (), or after tracking the command window to calculate the value of the object and other methods.
In fact, Microsoft provides good output Debug class trace for asp.net. Here's how it's used.
(ii) Specific use

Divided into page-level debugging and application-level tracing debugging:
1. Page-level tracking: Include the following page directives at the beginning of the page <%@ page trace= "True" tracemode= "Sortbycategory/sortbytime"%>
I. Custom Message Example:
Trace.Write ("Here is the variable or custom string to output the result");
Trace.Warn ("Here is the string to display"); Same as Trace.Write, except the font is red
Check if tracking is used

Ii. determine if trace output is enabled:
if (trace.isenabled) {Trace.Warn ("tracing Enabled")}


2. Application-level tracking:
<trace enabled= "true" pageoutput= "true" in the <System.Web> section of the web.config file/>
This does not have to be set on a single page.


The biggest benefit of tracing with trace is that when a programmer finishes using it, the page or application trace is set to: false.

You don't have to delete it or comment it. Because the compiler compiles to the trace output
Statement is not compiled, it skips the trace statement and continues to compile the following statement.

From a programmer's point of view, trace is equivalent to having commented out



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.