Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colorize logs in eclipse console

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.

like image 362
Newtopian Avatar asked Oct 24 '08 14:10

Newtopian


People also ask

How do I change the color of my console log in Eclipse?

To change a color, click on the colored button next to the desired console output type and select a new color. Check this box if want to have SVN messages sent to the Eclipse console. Checking this option will force the Console tab to the front when SVN writes an error message to the Console.

How do I use console log in Eclipse?

On the menu bar in eclipse, go to Window->Show View->Console. When you run the program, that console window should be where your System.

How do I change text color in Eclipse?

All of these colors can be adjusted via the following preference pages: General > Appearance > Colors and Fonts > Basic (Error text, hyperlink text, active hyperlink text) General > Editors > Text Editors (Foreground, background and other appearance colors)

How do I get all logs in Eclipse?

For that, go to Run -> Debug Configurations on Eclipse menu. Then under "Standard Input and Output" section, click on checkbox next to "File:", and choose the name of output file to use. If you check "Append" underneath, console output will be appended to the output file.


2 Answers

Have a try with this Eclipse Plugin: Grep Console

[Update]:
As pointed out by commenters: When installing Grep Console in the currently last version of Eclipse, you need to uncheck 'Group items by category' in the Install dialog to see the available items.
As pointed out by @Line the plugin can now be easily installed via the Eclipse Marketplace again without changing any options.

[Update 2]:
As pointed out by @azdev, to get proper highlighting:

Entering just literal strings doesn't work. To get a line to be colored, you have to enclose the string in .* on either side, like so: .*ERROR.*

like image 168
Benjamin Seiller Avatar answered Oct 24 '22 22:10

Benjamin Seiller


Actually the ANSI Console plugin adds ANSI escape code support to Eclipse console. At present it does have a limitation though, whereby escape codes that span multiple lines leak incorrectly to other lines when scrolling, see issue #3.

Otherwise some terminal view plugin as explained in this other question might be an option for some.

like image 45
fmjrey Avatar answered Oct 24 '22 22:10

fmjrey