作者 主題: MCSD .net: Tracing webpage application  (閱讀 2681 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
MCSD .net: Tracing webpage application
« 於: 2005-06-18 20:58 »
1.1 on the Web.config, to enable the application tracing, but not recommand because it will slow down the performance of the site seriously.  

<trace
        enabled="false"
        requestLimit="10"
        pageOutput="false"
        traceMode="SortByTime"
        localOnly="true"
    />

enabled must be true: enabled="true"

1.2 it is recommanded to trace certain pages, not the whole application, to trace certain page, you just need to add below code on your web page, that's done.
 
<%@ Page Trace="True" Tracemode="SortByTime" %>

2. browse to the page you want to trace, then browse the info page of tracing like:


http://61.142.73.250/test/trace.axd

3.you may also change the info page name from [trace.axd] to whatever page. The configure file is located in


C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG\machine.config


the original code is

<httpHandlers>

<add verb="*" path="*.vjsproj" type="System.Web.HttpForbiddenHandler"/><add verb="*" path="*.java" type="System.Web.HttpForbiddenHandler"/><add verb="*" path="*.jsl" type="System.Web.HttpForbiddenHandler"/><add verb="*" path="trace.axd" type="System.Web.Handlers.TraceHandler"/>

change the path="trace.axd" to for example "hello.axd"


4. <trace
        enabled="false"
        requestLimit="10"
        pageOutput="false"
        traceMode="SortByTime"
        localOnly="true"
    />

regarding to the file trace tag, pls notice change the localOnly="false", then enable the pc outside the intranet also can trace your pc.

pageOutput="true", will post the tracing info just on the web page you want to trace.

5. you may use the tracing object in your code like

[ Trace.write ] or
[ Trace.warn("AA", ds.Tables["區域"].Rows.Count.Tostring()) ]

or to sense the tracing feature is turn on or turn off.
[If Trace.IsEnable Then StrMsg="Tracing is enabled"]

or to enable or disable the tracing feature
[Trace.IsEnabled=False]

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
Put the Tracing code in component
« 回覆 #1 於: 2005-06-18 21:47 »
1. start one class library project
2. add reference on the dll :
[System.web.dll]

3.

add below code under using System;

[ using System.Web; ]




代碼: [選擇]
using System;
using System.Web;

namespace Class2
{
/// <summary>
/// Class1 的摘要描述。
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: 在此
//
}
public void CallMe()
{
HttpContext.Current.Trace.Warn("QQQ", "Class 1 --> CallMe()");
}

}
}



2. on the webpage new the instance of class, then call the method, the tracing messages would also shown on the trace.axd page