public final class MulticolorLayout extends PatternLayout
Use it in your LOG4J configuration:
log4j.rootLogger=INFO, CONSOLE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%-5p}] %c: %m%n
The part of the message wrapped with %color{...}
will change its color according to the logging level of the event. Without
this highlighting the behavior of the layout is identical to
PatternLayout
. You can use %color-red{...}
if you
want to use specifically red color for the wrapped piece of text. Supported
colors are: red
, blue
, yellow
, cyan
,
black
, and white
.
Besides that you can specify any ANSI color you like with
%color-<attr>;<bg>;<fg>{...}
, where
<attr>
is a binary mask of attributes,
<bg>
is a background color, and
<fg>
is a foreground color. Read more about
ANSI escape code.
Maven dependency for this class is (see How to use with Maven instructions):
<dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-log</artifactId> </dependency>
The class is immutable and thread-safe.
BUF_SIZE, DEFAULT_CONVERSION_PATTERN, MAX_CAPACITY, TTCC_CONVERSION_PATTERN
LINE_SEP, LINE_SEP_LEN
Constructor and Description |
---|
MulticolorLayout() |
Modifier and Type | Method and Description |
---|---|
String |
format(LoggingEvent event) |
void |
setConversionPattern(String pattern) |
activateOptions, createPatternParser, getConversionPattern, ignoresThrowable
getContentType, getFooter, getHeader
public void setConversionPattern(String pattern)
setConversionPattern
in class PatternLayout
public String format(LoggingEvent event)
format
in class PatternLayout
Copyright © 2012-2013 jcabi.com. All Rights Reserved.