TraceContext::Write Method (String^, String^, Exception^)

 

Writes trace information to the trace log, including any user-defined categories, trace messages, and error information.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public:
void Write(
	String^ category,
	String^ message,
	Exception^ errorInfo
)

Parameters

category
Type: System::String^

The trace category that receives the message.

message
Type: System::String^

The trace message to write to the log.

errorInfo
Type: System::Exception^

An Exception that contains information about the error.

Every time the Write method is called, a TraceContext trace message is added to the TraceRecords messages collection, which is accessible when you handle the TraceFinished event. The message is added with its IsWarning property set to false, and the ErrorInfo property is set to the object passed by the errorInfo parameter.

The following code example demonstrates how to call the Write method to write an error trace message to the trace log. In this example, different exceptions are traced as errors and warnings. When the page throws an ArgumentException, it writes a warning message using the Warn method. When the page throws an InvalidOperationException, it writes an error message using the Write method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: