Using the Grep-console plugin to make IntelliJ idea display multi-color debug logs

Source: Internet
Author: User
Tags log4j


Because IntelliJ idea does not support the display of ASCII color, Grep-console plug-in can solve this problem, the following is the development of Java EE Project, combined with LOG4J configuration multi-color log output function.







Installing the Grep-console plugin



Https://plugins.jetbrains.com/plugin/7125-grep-console Download the latest version





Idea's setup install plugin to select the downloaded zip package and restart it.








Set Grep-console Configure the foreground color of all levels of logs








Configure log4j



Maven config file pom.xml add log4j's Trust


[HTML]

 <dependency> <groupId>log4j</groupId> <artifactid& gt;log4j</artifactid> <version>1.2.17</version> </version> </dependency>

In the Resource folder, add the log.4j configuration file log4j.properties and add the following:


[HTML]

 ### set log levels ###   log4j.rootlogger =  debug ,  stdout      ###  output to console  ###   log4j.appender.stdout = org.apache.log4j.consoleappender   Log4j.appender.stdout.Target  = System.out   Log4j.appender.stdout.layout = org.apache.log4j.patternlayout    log4j.appender.stdout.layout.conversionpattern = %-d{yyyy-mm-dd hh:mm:ss}   [ %t:%r ] - [ %p ]  %m%n      ###  output to log file  ###   log4j.appender.d = org.apache.log4j.dailyrollingfileappender   log4j.appender.d.file = logs/log.log   log4j.appender.d.append = true   log4j.appender.d.threshold = debug ##  output DEBUG level above log    Log4j.appender.d.layout  = org.apache.log4j.patternlayout   log4j.appender.d.layout.conversionpattern = %-d{yyyy-mm-dd hh:mm:ss}   [ %t:%r ] - [ %p ]  %m%n      d.layout.conversionpattern = %-d{yyyy-mm-dd hh:mm:ss}  [ %t:%r ] -  [ %p ]  %m%n  

test the final effectApply JUnit to write the following test code[Java]

 @Test public void Testloger () {final Logger Logger = Logger.getlogger ("Testerrout");     Logger.debug ("This is DEBUG!!!"); &nb

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.