Reputation: 129
I want to color the log4j error logs with red.
I have gone through few links advising how to do that but following all the steps what i see on Eclipse or command console is something like [[31m INFO[m]
and not the color. I guess plugin is required for both Eclipse and command for ANSI.
But I want to know if there is a way out where we do not require ANSI plugins.
Because Java System.err
logs do come out to console with red color.
Upvotes: 2
Views: 1339
Reputation: 5618
All the text sent to Java's System.err
is red in Eclipse console only because it was printed on process Standard Error
channel. To display Log4j logs in red in Eclipse console, you shall tell Log4j to also use this Standard Error channel, with such a line in your Log4j configuration file:
log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
log4j.appender.ConsoleAppender.Target=System.err
or if your configuration file is an XML configuration file:
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
....
<param name="target" value="System.err"/>
....
</appender>
Upvotes: 1