Writing Custom ASP.NET Trace Messages
ASP.NET tracing enables you to append custom trace information to the end of an ASP.NET page or to the trace log. The trace information written to the trace log is viewable with the trace viewer. For more information, see How to: View ASP.NET Trace Information with the Trace Viewer.
You can write trace information using the TraceContext class's Warn or Write methods. The difference between the two methods is that a message written with the Warn method appears in red text.
For information on enabling tracing for a page, see How to: Enable Tracing for an ASP.NET Page. For information on enabling tracing for an application, see How to: Enable Tracing for an ASP.NET Application.
The following code example demonstrates using the TraceContext class to display trace information at the end of an ASP.NET page. A different exception is thrown for each LinkButton control that caused the postback. The error message used to initialize the ArgumentException or InvalidOperationException is displayed in the trace log.