2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Eclipseでコンソールの出力を色分けする方法

Posted at

System.out.println()などを使ってコンソールにログを出力するようにしていると、コンソールログを確認したいときにログが埋もれて探すのが大変なことがあります。

Sample
public class Sample {
	public static void main(String[] args) {
		for (int i=0; i<10; i++) {
			if (i == 5) {
				System.out.println(i+"回目のループです。");
			}
			if (i%3==0) {
				System.out.println("Hoge Hoge");
			} else if (i%3==1) {
				System.out.println("Huga Huga");
			} else {
				System.out.println("Moku Moku");
			}
		}
	}
}

a.PNG

そういうときはSystem.err.printlnを使うと確認したい項目を赤色で表示することができます。Eclipseでは標準エラー出力は赤色で出力されるようになっているようです。(ちなみに標準入力は緑)

if (i == 5) {
    System.err.println(i + " times");
}

aa.PNG

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?