Get System.Diagnostics.Trace Output to you ASP.NET Page
Working on a new SP.NET page today, I was frustrated to discover that none of the debugging messages being written by the System.Diagnostics.Trace.Write method were showing in my page’s trace information area. I found out that in .NET 2.0, you have to explicitly enable sending System.Diagnostics.Trace to the ASP.NET page trace.
Add the following to your web.config:
<configuration>
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="WebPageTraceListener"
type="System.Web.WebPageTraceListener,
System.Web,
Version=2.0.3600.0,
Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Also, don’t forget to have your code compiled with the TRACE compilation constant defined.
Thanks to Alex Thissen for his article on this topic.
