Enabling Page Level Tracing : Trace « Development « ASP.NET Tutorial






<%@ Page Language="C#" Trace="true" %>
<script runat="server">

    private void Page_Load(Object Source, EventArgs E)
    {
        Trace.Write("Page_Load", "Declaring and initializing variables.");
        int _A = 10;
        int _B = 20;
        
        Trace.Write("Page_Load", "Applying add operation.");
        _A += _B;
        
        Trace.Write("Page_Load", "Variable values changed.");
        Trace.Write("_A", _A.ToString());
        Trace.Write("_B", _B.ToString());
    }        

</script>
<html>
<head>
<title>Enabling Page Level Tracing</title>
</head>
<body>
    <form runat="server">
        <!-- Insert content here -->
    </form>
</body>
</html>








9.44.Trace
9.44.1.Trace.IsEnabled
9.44.2.Enable trace in Web.config
9.44.3.Enabling Page Level Tracing
9.44.4.Set Page.Trace.IsEnabled to true (C#)
9.44.5.Write warning message with Trace.Warn
9.44.6.Use Trace.Write to write message (C#)
9.44.7.Trace to a file