You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Curt Arnold <ca...@apache.org> on 2005/08/20 22:49:59 UTC

Colorized console output (was Re: question)

On Aug 17, 2005, at 4:24 PM, Yixing Ma wrote:

> Hi,
> Is there a way to change the color of debug, info, error and warn  
> in the console?


There was a rejected bug (http://issues.apache.org/bugzilla/ 
show_bug.cgi?id=19920) that contained one persons approach to the  
issue (with a patch which you could use for yourself).

A ConsoleAppender might not be writing to a console device, it may be  
redirected to a file or another application where the escape codes to  
add color might not be desired.  So it isn't desirable to  
unconditionally add color without some user configuration.  Also,  
since log4j console output could be interspersed with other console  
output, you'd need to make sure to reset the color after each message.

The layout would likely be the right place to add color.  For  
example, a colorized TelnetAppender would be equally valid as a  
colorized ConsoleAppender and placing it in the layout would allow  
both applications to share the supporting code.

I'm guessing the referenced patch only prints the level in color, for  
example, WARN in yellow.  I don't know if that is what you wanted, or  
if you'd like the entire message body in color.

I have on my long wish list to add a localizing layout that could  
make pattern substitutions in the logging process (http:// 
issues.apache.org/bugzilla/show_bug.cgi?id=32810).  If such a thing  
existed, you could "translate" the standard english text into text  
wrapped by VT-100 escape codes.  This use might make an interesting  
use case, if I ever get to that.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Colorized console output (was Re: question)

Posted by Nicolas Martignole <nm...@gmail.com>.
Hi 
I wrote a WriterAppender a while ago that uses ANSI colors.
It's like a ConsoleAppender, using ANSI colors.

See the full article here 
http://www.jroller.com/page/Trecollo/20041013

Nicolas Martignole

2005/8/20, Curt Arnold <ca...@apache.org>:
> 
> On Aug 17, 2005, at 4:24 PM, Yixing Ma wrote:
> 
> > Hi,
> > Is there a way to change the color of debug, info, error and warn
> > in the console?
> 
> 
> There was a rejected bug (http://issues.apache.org/bugzilla/
> show_bug.cgi?id=19920) that contained one persons approach to the
> issue (with a patch which you could use for yourself).
> 
> A ConsoleAppender might not be writing to a console device, it may be
> redirected to a file or another application where the escape codes to
> add color might not be desired.  So it isn't desirable to
> unconditionally add color without some user configuration.  Also,
> since log4j console output could be interspersed with other console
> output, you'd need to make sure to reset the color after each message.
> 
> The layout would likely be the right place to add color.  For
> example, a colorized TelnetAppender would be equally valid as a
> colorized ConsoleAppender and placing it in the layout would allow
> both applications to share the supporting code.
> 
> I'm guessing the referenced patch only prints the level in color, for
> example, WARN in yellow.  I don't know if that is what you wanted, or
> if you'd like the entire message body in color.
> 
> I have on my long wish list to add a localizing layout that could
> make pattern substitutions in the logging process (http://
> issues.apache.org/bugzilla/show_bug.cgi?id=32810).  If such a thing
> existed, you could "translate" the standard english text into text
> wrapped by VT-100 escape codes.  This use might make an interesting
> use case, if I ever get to that.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org