I would recommend wraping appender app log4net in the class and adding indentation support there. We are doing something similar to StringBuilder. We created the FormattedStringBuilder class, which has methods for increasing and decreasing the indentation level.
private const string Indent = "\ t";
private readonly int IndentLength = Indent.Length;
public void IncreaseIndent ()
{
// Increase indent
indentLevel ++;
indentBuffer.Append (Indent);
// If new line already started, insert another indent at the beginning
if (! useIndent)
{
contentBuffer.Insert (0, Indent);
}
}
public void DecreaseIndent ()
{
// Only decrease the indent to zero.
if (indentLevel> 0)
{
indentLevel--;
// Remove an indent from the string, if applicable
if (indentBuffer.Length! = 0)
{
indentBuffer.Remove (indentBuffer.Length - IndentLength, IndentLength);
}
}
}
source share