Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ render ANSI colors in plain text file

I just learned that it's possible to color output in java console using ANSI escape sequences. The below for instance:

final String RED_COLOR_CODE = "\u001B[31m";
final String RESET_CODE = "\u001B[0m";
System.out.println(RED_COLOR_CODE + "This is red output" + RESET_CODE);

would print 'This is red output' to the console in red.

If I use a PrintStream to print exactly the same to a plain text file:

PrintStream ps = new PrintStream("foo/log.log");
ps.println(RED_COLOR_CODE + "This is red output" + RESET_CODE);
ps.close();

and then I open the file in Intellij editor I get ' [31mThis is red output [0m' in black. Is there a configuration or maybe a plugin for IntelliJ that would allow the rendering of ANSI escape sequences in the editor similarly to console?

like image 446
ALTN Avatar asked Oct 20 '25 14:10

ALTN


2 Answers

It's not possible at the moment, vote for this related request:

  • IDEA-172142 ANSI Color and formatting support for .log files

See also this forum discussion.

like image 136
CrazyCoder Avatar answered Oct 23 '25 08:10

CrazyCoder


For those interested, here's a plugin that should do while on the wait for official support by JetBrains.

like image 33
ALTN Avatar answered Oct 23 '25 06:10

ALTN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!