TraceContext::Warn Method (String^, String^, Exception^)
Writes trace information to the trace log, including any user-defined categories, trace messages, and error information. All warnings appear in the log as red text.
Assembly: System.Web (in System.Web.dll)
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 Warn 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 true, 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.
Available since 1.1