logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <pbened...@apache.org>
Subject Re: [v2] Color console events per level
Date Thu, 01 Nov 2012 13:54:54 GMT
fatal: magenta (or red)
error: red (or magenta)
warning: info
info: green
debug: cyan
trace: black (which is really dark gray)

I think INFO, which is the standard logging level, should just be white.

I also think DEBUG and TRACE should share the same color. Perhaps like a
pale light purple that doesn't "shout" with its color.


On Thu, Nov 1, 2012 at 8:48 AM, Gary Gregory <garydgregory@gmail.com> wrote:

> OK, we/I need to tweak the highlighter's default colors because for me, on
> Windows 7, the default colors are not good (bold does not seem to do
> anything):
>
> fatal: red
> error: red
> warning: red
> info: dark blue
> debug: default
> trace: default
>
> I propose that each level have its own color.
>
> How about:
>
> fatal: magenta (or red)
> error: red (or magenta)
> warning: info
> info: green
> debug: cyan
> trace: black (which is really dark gray)
>
> Gary
>
>
>
>
> On Thu, Nov 1, 2012 at 8:05 AM, Gary Gregory <garydgregory@gmail.com>wrote:
>
>> Great. Thanks for the pointers.
>>
>> Gary
>>
>> On Nov 1, 2012, at 2:23, Ralph Goers <ralph.goers@dslextreme.com> wrote:
>>
>> The coloring isn't done by the layout but by the StylePatternConverter
>> and the HighlightPatternConverter. Rather than creating a new converter you
>> can simply enhance the HighlightPatternConverter to accept the styling. So
>> in addition to being able to do
>>
>> <pattern>%d %highlight{%p} %style{%C{1.} [%t] %m}{bold,green}%n</pattern>
>>
>> you could also do
>>
>> <pattern>%d %highlight{%p}{FATAL=magenta bold, ERROR=red, WARN=yellow
>> bold, INFO=green} %style{%C{1.} [%t] %m}{bold,green}%n</pattern>
>>
>> Ralph
>>
>> On Oct 31, 2012, at 7:40 PM, Gary Gregory wrote:
>>
>> Hi All:
>>
>> Nice job getting JAnsi support in Log4J2!
>>
>> I have a custom appender I use for 1.2 to color whole lines based on the
>> level with some sensible defaults the use can override. For example:
>>
>>
>> log4j.appender.ColorConsole=com.seagullsw.toolbox.log4j.AnsiConsoleAppender
>> log4j.appender.ColorConsole.ImmediateFlush=true
>> log4j.appender.ColorConsole.Target=System.out
>> log4j.appender.ColorConsole.layout=org.apache.log4j.EnhancedPatternLayout
>> log4j.appender.ColorConsole.layout.ConversionPattern=%d{ISO8601} [%t]
>> %-5p: %m%n
>>
>> #log4j.appender.ColorConsole.FatalColor=\u001b[1;35m
>> #log4j.appender.ColorConsole.ErrorColor=\u001b[1;31m
>> #log4j.appender.ColorConsole.WarnColor=\u001b[0;33m
>> #log4j.appender.ColorConsole.InfoColor=\u001b[0;32m
>> #log4j.appender.ColorConsole.DebugColor=\u001b[0;36m
>> #log4j.appender.ColorConsole.TraceColor=\u001b[1;30m
>>
>> log4j.appender.ColorConsole.FatalColor=//bold magenta
>> log4j.appender.ColorConsole.ErrorColor=//bold red
>> log4j.appender.ColorConsole.WarnColor=//bold yellow
>> log4j.appender.ColorConsole.InfoColor=//green
>> log4j.appender.ColorConsole.DebugColor=//cyan
>> log4j.appender.ColorConsole.TraceColor=//bold black
>>
>> To do this a la log4j (1 and 2) though, it seems that the work should be
>> done in the layout and not in the appender.
>>
>> But right now, I do not see a way to color the whole line (or part of a
>> line for that matter) based on the level for a given event.
>>
>> I can do fancy formatting like:
>>
>>       <PatternLayout pattern="%style{%d{ ISO8601 }}{black}
>> %style{[%t]}{blue} %style{%-5level:}{yellow}
>> %style{%msg%n%throwable}{green}" />
>>
>> But that's not what I want. So I am considering putting more smarts in
>> PatternLayout.
>>
>> Does that seem sensitive?
>>
>> What should the configuration look like and how would you let it use
>> defaults if some levels are not matched with colors?
>>
>> How about a new converter called level-style? For example:
>>
>> Use default colors:
>>
>> <PatternLayout pattern="%level-style{%d{ ISO8601 } [%t] %-5level:
>> %msg%n%throwable}" />
>>
>> Use custom colors:
>>
>> <PatternLayout pattern="%level-style{%d{ ISO8601 } [%t] %-5level:
>> %msg%n%throwable}{FATAL=magenta bold, ERROR=red, WARN=yellow bold,
>> INFO=green}" />
>>
>> Your thoughts please.
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
>> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Mime
View raw message