The TraceListener class has an "IndentLevel" property that you can access to
obtain the level of indenting you should use. Here is an example I wrote
for you:
class Class1
{
public Class1(string[] args)
{
System.Diagnostics.Debug.Listeners.Clear();
System.Diagnostics.Debug.Listeners.Add(new DateStampTraceLisener());
Debug.WriteLine("Testing");
Debug.Indent();
Debug.WriteLine("Testing Indent");
}
#region Application Entry Point
[STAThread]
static void Main(string[] args)
{
new Class1(args);
Console.WriteLine("\nPress [ENTER] to exit...");
Console.ReadLine();
}
#endregion
}
class DateStampTraceLisener : TraceListener
{
public override void Write(string info)
{ Console.WriteLine("".PadLeft(IndentLevel * 2, ' ') + DateTime.Now + "
" + info); }
public override void WriteLine(string info)
{ Write(info + "\n"); }
}
"CGuy" <cg**@csharp.net> wrote in message
news:ui**************@tk2msftngp13.phx.gbl...
Hi,
I have a question. I have implemented a custom trace listener (derived
from the TextWriterTraceListener type).
Now, I add this custom trace listener to the list of listeners and then
call a Trace.Indent() before I write to the trace. But the file produced by my
CustomTraceListener does not indent the text. How do I do this?
CGuy