1.首先在eclipse中安装一个插件: ANSI COLOR
在Eclipse Marketplace 中直接搜索 ANSI COLOR 然后安装
2.在log4j 中加入红色字体部分:
<Console name="SlowConsole" target="SYSTEM_OUT">
<PatternLayout Pattern="%-d{MMdd HH:mm:ss,SSS} %high1ight{%-5p %m%n} {FATAL—red , ERROR—red , WARN-yellow , INFO-white , DEBUG—green , TRACE-b1ue , TRACE-blue}"/>
</Console>
颜色可以参考:http://logging.apache.org/log4j/2.x/manual/layouts.html
3.开发完成之后,要发布时必须再引用一个包:
<!-- https://mvnrepository.com/artifact/org.fusesource.jansi/jansi --> <dependency> <groupId>org.fusesource.jansi</groupId> <artifactId>jansi</artifactId> <version>1.15</version> </dependency>