Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B4878D779 for ; Thu, 1 Nov 2012 17:09:19 +0000 (UTC) Received: (qmail 59641 invoked by uid 500); 1 Nov 2012 17:09:19 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 59605 invoked by uid 500); 1 Nov 2012 17:09:19 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 59595 invoked by uid 99); 1 Nov 2012 17:09:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2012 17:09:19 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_DBL_REDIR X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of garydgregory@gmail.com designates 209.85.210.47 as permitted sender) Received: from [209.85.210.47] (HELO mail-da0-f47.google.com) (209.85.210.47) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2012 17:09:14 +0000 Received: by mail-da0-f47.google.com with SMTP id s35so1206576dak.34 for ; Thu, 01 Nov 2012 10:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ai+9nt/xgCZ8lkxGjDyz+JTn8QQSG55CHpVUNPpWgbc=; b=kj1fcT6diCrfjwrVm9A2GCPfU4L2mSVSlaoQvKJTidRv4+WGyPkVOX/Mtl9AGDKpGO DtlFykEzsHtC55ID61qNbL7kwLp0u1f6Hk7ya/suAdcNNzaOTW1+9kVvziNzJV5yM90R FuvYF5c4BeysHUPtipvH2Ct0HegV+Sar9E5II0Uxmqy2r0a7Dz3H4/hWvqEliQ00PunM Wj8PF8fOmakkM9SdJqg2Ca2dONAwkoR+Efy4YKw71JcLoye5f85atYuvvCZbmRDBavAQ X/3XwGn5p84/LbIA9Z5hu5+5E7aQONRn7i7tb64l33dzk+wbNHLdLS1sdIwU8ybUZVPx qj/g== MIME-Version: 1.0 Received: by 10.68.232.201 with SMTP id tq9mr36980920pbc.12.1351789734546; Thu, 01 Nov 2012 10:08:54 -0700 (PDT) Received: by 10.68.40.130 with HTTP; Thu, 1 Nov 2012 10:08:54 -0700 (PDT) In-Reply-To: References: <7AA0216E-4C06-4F35-B42C-45D545FEE7E9@dslextreme.com> <5305274512474289527@unknownmsgid> <91F58E73-C243-4827-9A51-52263A179440@dslextreme.com> Date: Thu, 1 Nov 2012 13:08:54 -0400 Message-ID: Subject: Re: [v2] Color console events per level From: Gary Gregory To: Log4J Developers List Content-Type: multipart/alternative; boundary=047d7b33d650f04c3d04cd721287 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b33d650f04c3d04cd721287 Content-Type: text/plain; charset=UTF-8 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 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 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 wrote: >> >>> On Thu, Nov 1, 2012 at 9:54 AM, Paul Benedict 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: >>> >>> >>> >>> Right now, I have this working in SVN: >>> >>> >>> >>> Gary >>> >>>> >>>> >>>> >>>> On Thu, Nov 1, 2012 at 8:48 AM, Gary Gregory 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 wrote: >>>>> >>>>>> Great. Thanks for the pointers. >>>>>> >>>>>> Gary >>>>>> >>>>>> On Nov 1, 2012, at 2:23, Ralph Goers >>>>>> 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 >>>>>> >>>>>> %d %highlight{%p} %style{%C{1.} [%t] >>>>>> %m}{bold,green}%n >>>>>> >>>>>> you could also do >>>>>> >>>>>> %d %highlight{%p}{FATAL=magenta bold, ERROR=red, WARN=yellow >>>>>> bold, INFO=green} %style{%C{1.} [%t] %m}{bold,green}%n >>>>>> >>>>>> 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: >>>>>> >>>>>> >>>>>> >>>>>> 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: >>>>>> >>>>>> >>>>>> >>>>>> Use custom colors: >>>>>> >>>>>> >>>>>> >>>>>> Your thoughts please. >>>>>> >>>>>> Gary >>>>>> >>>>>> -- >>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org >>>>>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0 >>>>>> Spring Batch in Action: 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://bit.ly/ECvg0 >>>>> Spring Batch in Action: 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://bit.ly/ECvg0 >>> Spring Batch in Action: 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://bit.ly/ECvg0 > Spring Batch in Action: 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://bit.ly/ECvg0 Spring Batch in Action: http://bit.ly/bqpbCK Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory --047d7b33d650f04c3d04cd721287 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I was going to have "STYLE=3DDefault" but we can also have "= STYLE=3DLog4J"

Gary

On Thu, N= ov 1, 2012 at 12:44 PM, Ralph Goers <ralph.goers@dslextreme.com> wrote:
I suppos= e STYLE=3DLog4j 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, a= t 9:23 AM, Gary Gregory wrote:


Will do...

Gary
=C2=A0

Ralph



On Nov 1, 2012, at 8:56 = AM, Paul Benedict wrote:

I think your latest suggestion is perfectly alright. I would just prefer WA= RN 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: infoinfo: 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 metaph= or: green means "go" or "all is well". But I could go w= ith 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=3D= cyan and TRACE=3DDark (which is really grey) or magenta?

I wonder if we should have some predefined style maps, like a Logback s= tyle:

<PatternLayout pattern=3D"%highlight{%d{ ISO8601 } [%t= ] %-5level: %msg%n%throwable}{STYLE=3DLogback}" />

Ri= ght now, I have this working in SVN:

<PatternLayout pattern=3D"%highlight{%d{ ISO8601 } [%t] %-5leve= l: %msg%n%throwable}{FATAL=3Dwhite, ERROR=3Dred, WARN=3Dblue, INFO=3Ddar= k, DEBUG=3Dgreen, TRACE=3Dblue}" />

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 go= od (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.=C2=A0

Gary

On Nov 1, 2012, at 2:23, Ralph Goers <ralph.goers@dslextreme.com= > wrote:

The coloring isn&#= 39;t done by the layout but by the StylePatternConverter and the HighlightP= atternConverter. Rather than creating a new converter you can simply enhanc= e the HighlightPatternConverter to accept the styling. So in addition to be= ing 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=3Dmagenta bo= ld, ERROR=3Dred, WARN=3Dyellow bold, INFO=3Dgreen} %style{%C{1.} [%t] %m}{b= old,green}%n</pattern>

Ralph

On Oct 31, 2012, at 7:40 PM, G= ary Gregory wrote:

Hi All:

Nice j= ob getting JAnsi support in Log4J2!

I have a custom appender I use for 1.2 to color whole lines based on th= e level with some sensible defaults the use can override. For example:
<= br>log4j.appender.ColorConsole=3Dcom.seagullsw.toolbox.log4j.AnsiConsoleApp= ender
log4j.appender.ColorConsole.ImmediateFlush=3Dtrue
log4j.appender.ColorCo= nsole.Target=3DSystem.out
log4j.appender.ColorConsole.layout=3Dorg.apach= e.log4j.EnhancedPatternLayout
log4j.appender.ColorConsole.layout.Convers= ionPattern=3D%d{ISO8601} [%t] %-5p: %m%n

#log4j.appender.ColorConsole.FatalColor=3D\u001b[1;35m
#log4j.append= er.ColorConsole.ErrorColor=3D\u001b[1;31m
#log4j.appender.ColorConsole.W= arnColor=3D\u001b[0;33m
#log4j.appender.ColorConsole.InfoColor=3D\u001b[= 0;32m
#log4j.appender.ColorConsole.DebugColor=3D\u001b[0;36m
#log4j.appender.C= olorConsole.TraceColor=3D\u001b[1;30m

log4j.appender.ColorConsole.Fa= talColor=3D//bold magenta
log4j.appender.ColorConsole.ErrorColor=3D//bol= d red
log4j.appender.ColorConsole.WarnColor=3D//bold yellow
log4j.appender.Col= orConsole.InfoColor=3D//green
log4j.appender.ColorConsole.DebugColor=3D/= /cyan
log4j.appender.ColorConsole.TraceColor=3D//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 d= o fancy formatting like:

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <PatternL= ayout pattern=3D"%style{%d{ ISO8601 }}{black} %style{[%t]}{blue} %styl= e{%-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 level= s are not matched with colors?

How about a new converter called level-style? For example:

Use d= efault colors:

<PatternLayout pattern=3D"%level-style{%d{ IS= O8601 } [%t] %-5level: %msg%n%throwable}" />

Use custom colo= rs:

<PatternLayout pattern=3D"%level-style{%d{ ISO8601 } [%t] %-5le= vel: %msg%n%throwable}{FATAL=3Dmagenta bold, ERROR=3Dred, WARN=3Dyellow bol= d, INFO=3Dgreen}" />

Your thoughts please.

Gary=

--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
Spring Batch in Action: = http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygreg= ory.com/
Tweet! http://twitter.com/GaryGregory

<= /span>



--
E-Mail: garydgregory@gmail.com | ggregory@apache.org =
JUnit in Action, 2nd Ed: http://bit.ly/ECv= g0
Spring Batch in Action: 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://bit.ly/ECv= g0
Spring Batch in Action: 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://bit.ly/ECv= g0
Spring Batch in Action: 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://bit.ly/ECvg= 0
Spring Batch in Action: http://bit.ly/bqpbCK
Blog: http:= //garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory=
--047d7b33d650f04c3d04cd721287--