Reputation: 540
The following code returns trace output just fine in Visual Studios however when I try to run the same code on IIS in an aspx page it stops working. Is this possible and if so what am I missing?
System.Diagnostics.Trace.AutoFlush = true;
StringBuilder traceBuilder = new StringBuilder();
StringWriter stringWriter = new StringWriter(traceBuilder);
using (System.Diagnostics.TextWriterTraceListener textWriterTraceListener = new TextWriterTraceListener(stringWriter))
{
System.Diagnostics.Trace.Listeners.Add(textWriterTraceListener);
System.Diagnostics.Trace.WriteLine("HELLO WORLD!");
System.Diagnostics.Trace.Flush();
textWriterTraceListener.Flush();
}
stringWriter.Flush();
string traceOutput = traceBuilder.ToString();
HttpContext.Current.Response.Write("traceOutput - " + traceOutput);
Upvotes: 1
Views: 328
Reputation: 540
Had to add the following to the web.config file:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp"
extension=".cs"
compilerOptions="/d:TRACE"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1" />
</compilers>
</system.codedom>
Upvotes: 1