
Hello all, Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful. [1] http://logback.qos.ch/manual/layouts.html#coloring -- Ceki http://twitter.com/#!/ceki

I'm on my mobile at the moment so I can't look at highlight.xml. I would assume that this file controls the color to log level mapping? I wrote a custom encoder a while ago that essentially does this, however, am happy to upgrade to the latest logback and see if it will work for us. if so, I'm happy to use it and have one less dependency. will check later this morning. --adam On Jun 7, 2012, at 2:49, ceki <ceki@qos.ch> wrote:
Hello all,
Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful.
[1] http://logback.qos.ch/manual/layouts.html#coloring -- Ceki http://twitter.com/#!/ceki _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Hi Adam, Color control is done within the pattern by color converters which are just composite converters, i.e. converters containing other conveters. Here is a sample "pattern" property: <pattern>%highlight(%-5level) %cyan(%logger) - %msg%n</pattern> Note the %highlight and %cyan composite conversion specifiers which contain other conversion specifiers (you can have as many as you want). For instance, the following is legal: <pattern>%highlight(%-5level %logger - %msg)%n</pattern> The %highlight specifier is implemented by HighlightingCompositeConverter [1] all in about 10 lines of code. [1] http://goo.gl/YJA8T -- Ceki http://twitter.com/#!/ceki On 07.06.2012 15:53, Adam Gordon wrote:
I'm on my mobile at the moment so I can't look at highlight.xml. I would assume that this file controls the color to log level mapping?
I wrote a custom encoder a while ago that essentially does this, however, am happy to upgrade to the latest logback and see if it will work for us. if so, I'm happy to use it and have one less dependency.
will check later this morning.
--adam
On Jun 7, 2012, at 2:49, ceki<ceki@qos.ch> wrote:
Hello all,
Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful.
[1] http://logback.qos.ch/manual/layouts.html#coloring -- Ceki http://twitter.com/#!/ceki

Ack. Sorry. That wasn't clear. Who controls [ERROR] being red, for example? That was the question I was trying to ask. If the highlight.xml file is what controls this, along with the ability to set the actual terminal codes (our terminal codes add bold, e.g., to some of the log levels), I believe we can use this. --adam http://gordonizer.com On Jun 7, 2012, at 8:49 AM, ceki wrote:
Hi Adam,
Color control is done within the pattern by color converters which are just composite converters, i.e. converters containing other conveters. Here is a sample "pattern" property:
<pattern>%highlight(%-5level) %cyan(%logger) - %msg%n</pattern>
Note the %highlight and %cyan composite conversion specifiers which contain other conversion specifiers (you can have as many as you want).
For instance, the following is legal:
<pattern>%highlight(%-5level %logger - %msg)%n</pattern>
The %highlight specifier is implemented by HighlightingCompositeConverter [1] all in about 10 lines of code.
[1] http://goo.gl/YJA8T -- Ceki http://twitter.com/#!/ceki
On 07.06.2012 15:53, Adam Gordon wrote:
I'm on my mobile at the moment so I can't look at highlight.xml. I would assume that this file controls the color to log level mapping?
I wrote a custom encoder a while ago that essentially does this, however, am happy to upgrade to the latest logback and see if it will work for us. if so, I'm happy to use it and have one less dependency.
will check later this morning.
--adam
On Jun 7, 2012, at 2:49, ceki<ceki@qos.ch> wrote:
Hello all,
Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful.
[1] http://logback.qos.ch/manual/layouts.html#coloring -- Ceki http://twitter.com/#!/ceki
Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Hello Ceki, 2012/6/7 ceki <ceki@qos.ch>:
Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful.
I actually started using it for logging during development. But my ide (eclipse) does not support taking notice of the ANSI colors. So I had to use an additional eclipse extension: http://www.mihai-nita.net/eclipse/ There are some little bugs with this combination, which I had no time to investigate. E.g. after an error log message, the whole output changes its color saturation. But at the moment I find it useful. Regards, Lars

On 07.06.2012 16:50, Lars Fischer wrote:
I actually started using it for logging during development. But my ide (eclipse) does not support taking notice of the ANSI colors.
So I had to use an additional eclipse extension: http://www.mihai-nita.net/eclipse/
Thank you for mentioning this plug-in. I did not know about it. Just tried it in a small application, and it seems to work.
There are some little bugs with this combination, which I had no time to investigate. E.g. after an error log message, the whole output changes its color saturation.
If you thinks it's a logback problem, don't hesitate to report a bug.
But at the moment I find it useful.
Cool,
Regards, Lars -- Ceki http://twitter.com/#!/ceki

There are some little bugs with this combination, which I had no time to investigate. E.g. after an error log message, the whole output changes its color saturation.
That sounds suspiciously like someone forgot to reset the terminal code back to normal from red. Here's what we use in our encoder: // Attribute codes: // 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed // // Text color codes: // 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white public static final String COLOR_YELLOW = "\033[1;33m"; public static final String COLOR_NEUTRAL = "\033[0m"; public static final String COLOR_ALL = "\033[0m"; public static final String COLOR_ERROR = "\033[01;31m"; public static final String COLOR_WARN = "\033[01;35m"; public static final String COLOR_INFO = "\033[01;34m"; public static final String COLOR_DEBUG = "\033[01;36m"; public static final String COLOR_TRACE = "\033[0;37m"; public static final String COLOR_DEFAULT = "\033[0m"; After every log statement, we have to append COLOR_DEFAULT to change it back to normal (we color our entire log message the same color). --adam http://gordonizer.com On Jun 7, 2012, at 8:50 AM, Lars Fischer wrote:
Hello Ceki,
2012/6/7 ceki <ceki@qos.ch>:
Has anyone had a chance to try ANSI coloring [1] as introduced in logback 1.0.5? It's a seemingly cool feature but I am curious whether it's actually useful.
I actually started using it for logging during development. But my ide (eclipse) does not support taking notice of the ANSI colors.
So I had to use an additional eclipse extension: http://www.mihai-nita.net/eclipse/
There are some little bugs with this combination, which I had no time to investigate. E.g. after an error log message, the whole output changes its color saturation.
But at the moment I find it useful.
Regards, Lars _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (3)
-
Adam Gordon
-
ceki
-
Lars Fischer