Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1392

Improve support for the JANSI library in ConsoleAppender

    XMLWordPrintable

Details

    Description

      The JANSI library provides an AnsiPrintStream that intercepts ANSI sequences and allows the application to react to them accordingly. Jansi is compatible with a variety of terminals, including xterm-like terminals for Windows like Mintty and MinGW.

      Jansi has a good algorithm to detect whether or not ANSI sequences will be correctly interpreted or not, and if not, its default behavior is to filter out such sequences.

      Logback's ConsoleAppender has a withJansi option. Unfortunately, Logback bypasses Jansi's detection algorithm and boldly assumes that if the OS is Windows, then the terminal is a DOS prompt. So while DOS prompts get colored, terminals like Mintty or MinGW not only lose their coloring but are sent DOS escape sequences that they can't interpret.

      We could improve support for JANSI with the following ideas:

      • Amend ConsoleAppender so that when withJansi is true, then every OutputStream is wrapped in an AnsiPrintStream, effectively delegating to the JANSI library the decision to filter out ANSI escape sequences or not, depending on the terminal capability. This also allows users to disable or customize the coloring behavior by using system properties recognized by JANSI, such as jansi.strip.
      • Amend the documentation and stress that the JANSI library is the recommended solution for Windows systems, as well as for cross-platform deployments that include a mix of Windows and non-Windows systems.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            adutra Alexandre Dutra
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: