我是靠谱客的博主 专一钢笔,最近开发中收集的这篇文章主要介绍Page Tracing Enabling Tracing,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 Enabling Tracing

<%@ Page Trace= " true " ...  %>
or 
protected  void Page_Load(Object sender, EventArgs e)
{
    Trace.IsEnabled =  true;
}
By default, trace messages are listed in the order they were written by your code. Alternatively, you 
can specify that messages should be sorted by  category using the TraceMode attribute in the  
Page directive: 
<%@ Page Trace= " true " TraceMode= " SortByCategory "  %> 
or the TraceMode property of the Trace object in your code: 
Trace.TraceMode = TraceMode.SortByCategory;

 

Writing Trace Information

protected  void cmdWrite_Click(Object sender, EventArgs e) 

    Trace.Write( " About to place an item in session state. "); 
    Session[ " Test "] =  " Contents "
    Trace.Write( " Placed item in session state. "); 
}
or uses overloaded method:
protected  void cmdWriteCategory_Click(Object sender, EventArgs e)
{
  Trace.Write( " cmdWriteCategory_Click ",
     " About to place an item in session state. ");
  Session[ " Test "] =  " Contents ";
  Trace.Write( " cmdWriteCategory_Click ",
     " Placed item in session state. ");
}

 

Trace an exception

protected  void cmdError_Click(Object sender, EventArgs e) 

     try 
    { 
        DivideNumbers( 50); 
    } 
     catch (Exception err) 
    { 
        Trace.Warn( " cmdError_Click "" Caught Error ", err); 
    } 

 
private  decimal DivideNumbers( decimal number,  decimal divisor) 

     return number/divisor; 
}

 

Application-Level Tracing

To enable application-level tracing, you need to  modify settings in the web.config file, as  
shown here: 
< configuration > 
   < system.web > 
     < trace  enabled ="true"  requestLimit ="10"  pageOutput ="false"   /> 
    ... 
   </ system.web > 
</ configuration > 
To view tracing information, you request the trace.axd file in the web application’s root directory. This file doesn’t actually exist; instead, ASP.NET automa tically intercepts the request and interprets it as a request for the tracing information.  It will then list the most recent co llected requests, provided you’re making the request from the local machine or have enabled remote tracing

转载于:https://www.cnblogs.com/JasonBie/archive/2012/04/11/2442568.html

最后

以上就是专一钢笔为你收集整理的Page Tracing Enabling Tracing的全部内容,希望文章能够帮你解决Page Tracing Enabling Tracing所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部