Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to make System.out.println(...) in color in Eclipse?
How to make System.out.println(...) in color in Eclipse? [message #269358] Fri, 13 March 2009 17:16 Go to next message
Eclipse UserFriend
Originally posted by: www.nospam.net

Hi,

My program prints out a lot of messages to console. I hope that in some
conditions, the printing can be in red color so that I can be notified.

//regular printing messages

System.out.println("A lot of messages A");

if(specificCondition==true)
{
System.out.println("You need to be careful about this");
//System.err.println("You need to be careful about this");
}

System.out.println("A lot of messages B");

I know "System.err.println(...) shows up in red. However, the order of
its message is un-predictable. e.g. "You need to be careful about this"
may be shows up after "A lot of messages B" in console. And next run,
the order will be different again.

Thank you for your help.
Re: How to make System.out.println(...) in color in Eclipse? [message #269382 is a reply to message #269358] Mon, 16 March 2009 09:04 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
afaik you can't
but you can add pre's

eg:
public class ImportanceLogger {
public ImportanceLogger() {
}

public static void Log(int importance, String message) {
String pre = "";
if (importance > 0) {
for (int i = 0; i < importance; i++) {
pre += "-";
}
} else {
System.out.println(message);
return;
}
System.out.println(pre + ">\t" + message);
return;
}

public static void main(String[] args) {
for (int i = 0; i < 7; i++) {
Log(i, "importance = "+i);
}
}
}

which would output:
importance = 0
-> importance = 1
--> importance = 2
---> importance = 3
----> importance = 4
-----> importance = 5
------> importance = 6

greets
Re: How to make System.out.println(...) in color in Eclipse? [message #269385 is a reply to message #269358] Mon, 16 March 2009 09:14 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
probably you may look into logback

http://logback.qos.ch/consolePlugin.html
Previous Topic:what happened to my Tomcat server?
Next Topic:Axis, Tomact help needed
Goto Forum:
  


Current Time: Sat Apr 27 03:18:28 GMT 2024

Powered by FUDForum. Page generated in 0.08336 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top