Log4net
  1. Log4net
  2. LOG4NET-292

Managed ColoredConsoleAppender for .NET2/Mono.

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.11
    • Fix Version/s: 1.2.12
    • Component/s: Appenders
    • Labels:
      None

      Description

      The original ColoredConsoleAppender was written before the .NET framework (and Mono) had built-in support for console colors so it was written using Win32 API calls. The AnsiColorTerminalAppender, while it works, isn't understood by the Windows command prompt so there's no console appender that works on both environments.

      I'm attaching a replacement for both classes that uses the new (.NET 2) console colors and works on both platforms. It is based on the existing ColoredConsoleAppender. The color mapping values are not compatible with the previous version since this one uses the standard .NET 2 ConsoleColor enumeration values.

      1. ColoredConsoleAppender2.cs
        10 kB
        Pavlos Touboulidis
      2. config-examples.patch
        2 kB
        Pavlos Touboulidis

        Activity

        Hide
        Stefan Bodewig added a comment -

        I've renamed the class and made it compile on .NET 2.0 (automatic Has*Color properties in LevelColors). Other than that the code is in with svn revision 1197200.

        Do you think you could provide a small documentation snippet for http://logging.apache.org/log4net/release/config-examples.html which is based on https://svn.apache.org/repos/asf/logging/log4net/trunk/src/site/xdoc/release/config-examples.xml ?

        Show
        Stefan Bodewig added a comment - I've renamed the class and made it compile on .NET 2.0 (automatic Has*Color properties in LevelColors). Other than that the code is in with svn revision 1197200. Do you think you could provide a small documentation snippet for http://logging.apache.org/log4net/release/config-examples.html which is based on https://svn.apache.org/repos/asf/logging/log4net/trunk/src/site/xdoc/release/config-examples.xml ?
        Hide
        Pavlos Touboulidis added a comment -

        Indeed, ManagedColoredConsoleAppender makes more sense. Good call on the automatic properties, forgot all about them. Thanks.

        I've attached a patch for the configuration example. Is it OK?

        Show
        Pavlos Touboulidis added a comment - Indeed, ManagedColoredConsoleAppender makes more sense. Good call on the automatic properties, forgot all about them. Thanks. I've attached a patch for the configuration example. Is it OK?
        Hide
        Stefan Bodewig added a comment -

        Thanks!

        Patch applied as svn revision 1203145

        Show
        Stefan Bodewig added a comment - Thanks! Patch applied as svn revision 1203145

          People

          • Assignee:
            Unassigned
            Reporter:
            Pavlos Touboulidis
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development