Colorize logs in eclipse console

后端 未结 10 679
别那么骄傲
别那么骄傲 2020-12-07 08:45

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

相关标签:
10条回答
  • 2020-12-07 09:20

    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.

    0 讨论(0)
  • 2020-12-07 09:21

    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."

    0 讨论(0)
  • 2020-12-07 09:21

    Emoji

    You can use colors for text as others mentioned in their answers.

    But you can use emojis instead! for example you can use You can use ⚠️ for warning messages and

    0 讨论(0)
  • 2020-12-07 09:27

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

    0 讨论(0)
  • 2020-12-07 09:29

    As already pointed out by @Benjamin Grep Console is a great way to colorize output in the Console.

    I had made a short video to demonstrate how it worked and heard back from the Creator of the Grep Console plugin. He mentioned that Grep console 3 is has been released.

    Screen cast : http://www.youtube.com/watch?v=fXjgGZAxToc

    Update Sites

    Grep Console 2
    http://eclipse.musgit.com
    (requires Eclipse 3.4 (Ganymede) or higher and Java 5.0 or higher)

    Grep Console 3
    http://eclipse.schedenig.name
    (requires Eclipse 3.7 (Indigo) or higher and Java 6.0 or higher)

    0 讨论(0)
  • 2020-12-07 09:31

    You can use ANSI Escape in Console plugin for Eclipse. You'll need this so the Eclipse console can interpret ANSI Escape codes. Install it and restart Eclipse. Then you can use ANSI Color Codes to write in a certain color. Here's a list of ANSI Color Codes from another stackoverflow answer. Then you can do this:

    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_RED = "\u001B[31m";
    
    public static void main(String[] args) {
        System.out.println(ANSI_RED + "This text is red!" + ANSI_RESET);
    }
    

    I used this to create a Custom Formatter for the Console Handler so it shows logs from Logger in different levels with different colors (INFO logs in cyan, WARNING logs in yellow and SEVERE logs in red). Here's how I did it, if you're interested.

    0 讨论(0)
提交回复
热议问题