Tu enable tracing at different levels, do as under:
Application level: Application’s web.config, set
Page level: @Page directive, Trace attribute to True in web form’s html
Write trace to a file: web.config
Customizing Tracing:
Writing messages to trace log using Write and Warn method
Code Listing: Tracing
Code Listing: Trace
using System.Diagnostics;
private void Page_Error(object sender, System.EventArgs e )
{
if(Trace.IsEnabled)
{
string strMessage;
if(Request.Browser.AOL)
strMessage = “AOL Browser”;
else
strMessage = ”Non AOL Browser”;
Trace.Warn(“Error”, strMessage, Server.GetLastError());
}
Server.ClearError();
Response.Redirect(“Trace.aspx”);
}
No comments:
Post a Comment