logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [v2] Color console events per level
Date Thu, 01 Nov 2012 17:08:54 GMT
I was going to have "STYLE=Default" but we can also have "STYLE=Log4J"

Gary

On Thu, Nov 1, 2012 at 12:44 PM, Ralph Goers <ralph.goers@dslextreme.com>wrote:

> I suppose STYLE=Log4j would be the default.
>
> I'm not sure I know of any others but it leaves room for users to request
> them.
>
> Ralph
>
>
>
> On Nov 1, 2012, at 9:23 AM, Gary Gregory wrote:
>
> On Thu, Nov 1, 2012 at 12:11 PM, Ralph Goers <ralph.goers@dslextreme.com>wrote:
>
>> Yes. I also like the idea of STYLE=xxxx with a few options just to save
>> typing.
>>
>
> Options:
>
>    - Logback
>    - What else?
>
>
>
>>
>> If you haven't done it don't forget to update the web site documentation.
>>
>
> Will do...
>
> Gary
>
>
>>
>> Ralph
>>
>>
>>
>> On Nov 1, 2012, at 8:56 AM, Paul Benedict wrote:
>>
>> I think your latest suggestion is perfectly alright. I would just prefer
>> WARN to be yellow to meet the traffic light metaphor. Otherwise, I see
>> where you're going and agree.
>>
>> Paul
>>
>> On Thu, Nov 1, 2012 at 10:51 AM, Gary Gregory <garydgregory@gmail.com>wrote:
>>
>>> On Thu, Nov 1, 2012 at 9:54 AM, Paul Benedict <pbenedict@apache.org>wrote:
>>>
>>>> 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.
>>>
>>>
>>> Hi Paul:
>>>
>>> I was thinking of the traffic light metaphor: green means "go" or "all
>>> is well". But I could go with WHITE too I suppose.
>>>
>>> The color palette is limited to say the least. Magenta is what you can
>>> match to light purple.
>>>
>>> I can see FATAL and ERROR with the same color: red.
>>>
>>> I do want DEBUG and TRACE to be different. How about DEBUG=cyan and
>>> TRACE=Dark (which is really grey) or magenta?
>>>
>>> I wonder if we should have some predefined style maps, like a Logback
>>> style:
>>>
>>> <PatternLayout pattern="%highlight{%d{ ISO8601 } [%t] %-5level:
>>> %msg%n%throwable}{*STYLE=Logback*}" />
>>>
>>> Right now, I have this working in SVN:
>>>
>>> <PatternLayout pattern="%highlight{%d{ ISO8601 } [%t] %-5level:
>>> %msg%n%throwable}{*FATAL=white, ERROR=red, WARN=blue, INFO=dark,
>>> DEBUG=green, TRACE=blue*}" />
>>>
>>> Gary
>>>
>>>>
>>>>
>>>>
>>>> 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
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> 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
>
>
>


-- 
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