tags:

views:

967

answers:

1

I want my console appender to clear out the screen before each new write so there is only 1 msg displaying at a time. I have a second file appender to show the history. I was hoping for something like this:

  <appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="cls%newline %date %message%newline" />
    </layout>
  </appender>

Thank you in advance. -Dustin

A: 

If there is an escape sequence of any sort that will clear the screen, then try something like this:

<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%property{cls} %date %message%newline" />
  </layout>
</appender>

and then in your code before you configure log4net, set the log4net property "cls":

string cls = "escape-sequence-here";
log4net.GlobalContext.Properties["cls"] = cls;

where you assign the appropriate escape sequence to the string variable cls.

Eddie