views:

4269

answers:

6

Is there a way to colorize parts of logs in the eclipse console. I know I could send to error and standard streams and color them differently but I'm more looking someting in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed the colors in the string to have it colored in the logs.

It sure would help making the important bits stand out without resorting to weird layout, rather keep the layout to the log4j setups

here is an example of what I am looking for :

[INFO ] The grid is complete ....... false

where the bold parts would be in blue, this coloring can be controlled by the application to an extent. like so (tags are conceptual and arbitrary, but you get the idea):

log.info(String.format("The grid is complete ....... <blue>%s</blue>", isComplete ));


On a more general note it is the ability to embed meta information in the logs to help the presentation of these logs. Much like we tag web pages content to help the presentation of the information by CSS.

A: 

You may consider trying Apache Chainsaw (http://logging.apache.org/chainsaw/index.html) if you are already working with log4j. Lets you define colors and filtern and works with (nearly) zero configuration.

GHad
I have tried it a long time ago, it was very helpfull though I do not know if it can help me in this case. I expect it to enable me more granularity in how rows are colored, but I want more... I will try it tomorrow.
Newtopian
+1  A: 

What about use Logback and its property converter and log everything in log4j, that may allow you see the diferents levels on diferents colors.

Good luck!

EDIT: the eclipse plugin

David Santamaria
+3  A: 

We use the Ganymede Eclipse plugin where I work, and it works well.

http://sourceforge.net/projects/ganymede/

"A log4j plugin to Eclipse that works similar to chainsaw (SocketServer). Includes color, filtering, detailed information, and saves settings."

Neal Swearer
This is a great plugin too bad they don't have one for europa :(
mugafuga
Mighty confusing to have an Eclipse plugin called "ganymede".
JesperE
+1  A: 

I've used this plugin before, it lets you colourize lines of the log based on customized regex.

For example, when I was using it, any lines with the words error would be red, warning would be orange, info would be blue... etc.

Since it's regex, you could do anything. Set it up to make the line green whenever it starts with ">>>" and then prepend your message string with ">>>".

http://sourceforge.net/projects/logfiletools

+1  A: 

Read about the org.eclipse.ui.console.consolePatternMatchListeners extension point.

thSoft
thats the right way to do it, but i think the poster was hoping some one had done this for ansi escape sequences or html color codes.
aepurniet
+7  A: 

have a try with this Eclipse Plugin: Grep Console

Benjamin Seiller
grep console is perfect, wish you could save presets though. it would be nice if you could replace the text too (instead of just matching it), that way you could strip out color codes and apply them at the same time.
aepurniet
Like it too, a simple plugin, that does the job.
BoD