Colored Pattern Layout

Written by Ingo Thon (isthon a-t gmx d0t de)

My intention during writting this layout is that many peoples (or even I'm) using the Log4j system for giving extra messages what there gui applications currently are doing.

But it is often the case that someone can overlook important error messages because they have so many debug messages and if you turn of the debug messages you see the error messages immediatly but you can't get the reason.

only a few lines but you can get an idea.


At some day here will the documentation of the ColoredPatternLayout (source) be.

Windows

Currently it doesn't seem to work under win2k and higher, even if you add the line

DEVICE=%systemroot%\system32\ansi.sys
into your config.nt. If someone has some suggestions how I have to change the change the escape sequences or how I've (and other peoples have) to reconfigure my windows system please mail me

but maybe there is no solution http://www.javaworld.com/javaworld/javaqa/2002-12/02-qa-1220-console.html


copy of javadoc

A layout wich has the same functions as the Patternlayout.

But it also allows to let the output to be colored

The ColorStrings are formated as follows
"foreground/background/attribute" where

the following colors could be set

major parts of this class came from the apache ant AnsiColorLogger
example configuration (screenshot above)
  <appender name="appender" class="org.apache.log4j.ConsoleAppender">
    <layout class="util.log4j.ColoredPatternLayout">
      <param name="ConversionPattern" value="%d [%l] %p - %m%n"/>
      <param name="ErrorColor" value="red"/>
      <param name="DebugColor" value="blue/green/bright"/>
    </layout>
  </appender>
  


Last modified: Tue Sep 7 09:42:16 CEST 2004