Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

INFO: New Tracing Feature in ASP.NET


View products that this article applies to.

This article was previously published under Q306731

↑ Back to the top


Summary

This article provides information about the new tracing feature in ASP.NET. This article also describes how to configure this tracing feature.

↑ Back to the top


More information

The tracing feature allows you to track the execution of an application and view the results. You can enable tracing at the page level or the application level.

Enable Tracing at the Page Level

When you enable tracing at the page level, the trace output is added to the bottom of the page. The following code sample demonstrates how to enable tracing at the page level:

Visual Basic .NET
<%@Page Language="vb" Trace="true"%>
<script runat="server">
Public Function TracingTest(strNow as String) as String
    Trace.Write("Now() Value in the function", now())
    return "The time is: " & strNow
end Function
</script>

TracingTest result: <%=TracingTest(Now())%>
				
Visual C# .NET
<%@ Page Language="c#" Trace="true"%>
<script runat="server">
public string TracingTest(string strNow)
{
    Trace.Write("Now() Value in the function",DateTime.Now.ToString());
    return "The Time is: " + strNow;
}
</script>

Tracing Test Results:  <%=TracingTest(DateTime.Now.ToString())%>
				
Visual J# .NET
<%@ Page Language="VJ#" Trace="true"%>
<%@ import namespace = "System.Diagnostics" %>
<%@ import namespace = "System" %>

<script runat="server">

public System.String TracingTest(System.String strNow)
{
    Trace.Write("Now() Value in the function",DateTime.get_Now().ToString());
    return "The Time is: " + strNow;
}
</script>
Tracing Test Results:
<%=TracingTest(DateTime.get_Now().ToString())%>
				
When you run this page, both of the results from the function are written to the browser. You also see the information that tracing returns.

To remove the trace information, set the Trace attribute of the @ Page directive to false. You do not need to remove the Trace.Write statement. Notice that this is the TraceContext class, not the Trace class.

To enable tracing at the page level in Microsoft Visual Studio .NET, you can also set the trace property of the document to true in the Properties window.

Enable Tracing at the Application Level

To enable tracing at the application level, use the Web.config file. The following code sample demonstrates how to configure tracing at the application level in the Web.config file:
<configuration>
    <system.web>
        <trace enabled="true" requestLimit="10" pageOutput="true"
         traceMode="SortByTime" localOnly="true"/>
    </system.web>
</configuration>
				
When you enable tracing at the application level, you can use the pageOutput attribute to specify whether the trace output is displayed at the page level. If you set pageOutput to true, the output displays the same results as if you set the Trace attribute of the @ Page directive at the top of the page to true.

NOTE: The trace setting at the page level overrides the trace setting at the application level.

↑ Back to the top


References

For more information about tracing and trace configuration settings, refer to the Visual Studio .NET product documentation and the following MSDN documentation: For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
308626� INFO: Roadmap for Debugging in .NET Framework and Visual Studio .NET

↑ Back to the top


Keywords: KB306731, kbweb, kbinfo, kbdebug, kbconfig

↑ Back to the top

Article Info
Article ID : 306731
Revision : 9
Created on : 1/20/2004
Published on : 1/20/2004
Exists online : False
Views : 606