██████████████████████████████████████████████████████████████████████


Que:::: What is Tracing in ASP.NET?

1 comment:

Unknown said...

Tracing with ASP.NET
The new tracing features of ASP.NET allow us to simulate Response.Write() statements but not worry about removing the statements before we deploy our applications. Instead, imagine writing the same code as above, but instead of using Response.Write(), we use Trace.Write().

The Trace object is now an intrinsic page object, similar to Request, Response, Server, etc. It is accessible directly with our page code.

Let's take a brief look at the Trace class.

Trace class
Trace is exposed as a public property within ASP.NET pages. When we use the Trace property, we're working with an instance of the TraceContext class defined in the System.Web namespace.

The Trace class exposes two overloaded methods and two properties. The two methods,
Warn()
and
Write(),
both support two identical prototypes:

VB.NET
Copy Code
Public Sub [Warn | Write](category As String,
message As String,
errorInfo As Exception)
End Sub
Public Sub [Warn | Write](category As String,
message As String)
End Sub

C#
Copy Code
public void [Warn | Write](String category,
String message,
Exception errorInfo)
public void [Warn | Write](String category,
String message)

The category parameter is used to identify the category name to write the message value into. This will become more apparent when we use the Write() method in an example below. The third parameter that both Warn() and Write() support in their overloaded methods is errorInfo. This allows us to pass exception details into the trace system.