TraceContext::Write Method (String, String, Exception)
Writes trace information to the trace log, including any user-defined categories, trace messages, and error information.
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 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.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.