|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionClass Using the codeEdit your root web.config file of your ASP.NET project: <configuration>
<system.diagnostics>
<assert assertuienabled="false" logfilename="c:\Debug.log" />
<trace autoflush="true" indentsize="0">
<listeners>
<add type="AspNetDebugListener.DebugListener,AspNetDebugListener" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
How it works
public class DebugListener : TraceListener
{
public DebugListener() : this("Forks Asp.Net DebugTracer")
{
}
Filter the output string
string GetStatckTraceString()
{
string s = Environment.StackTrace;
StringBuilder sb = new StringBuilder(s.Length);
using (StringReader reader = new StringReader(s))
{
bool debugFound = false;
for(;;)
{
string line = reader.ReadLine();
if (line == null)
break;
if (line.IndexOf("System.Diagnostics.Debug.Assert") != -1)
{
debugFound = true;
continue;
}
if (debugFound)
{
sb.Append(line);
sb.Append(Environment.NewLine);
}
}
}
return sb.ToString();
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||