在eclipse控制台中着色日志 [英] Colorize logs in eclipse console

查看:171
本文介绍了在eclipse控制台中着色日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在eclipse控制台中对部分日志进行着色。我知道我可以发送错误和标准的流,并以不同的方式进行着色,但是我更倾向于在ANSI转义代码(或任何其他HTML?)的行列中,我可以将字符串中的颜色嵌入到日志。



它肯定有助于使重要的比赛脱颖而出,而不需要使用奇怪的布局,而是将布局保留在log4j设置中



这里是我正在寻找的例子:



[INFO]网格完成....... false



其中粗体部分将呈蓝色,此着色可由应用程序在一定程度上控制。像这样(标签是概念性的和任意的,但你得到的想法):



log.info(String.format(网格完成...... 。< blue> %s < / blue> ,isComplete));






在更一般的注意事项中,可以在日志中嵌入元信息来帮助显示这些日志。很像我们标记网页内容,以帮助CSS介绍信息。

解决方案

尝试使用此Eclipse插件:
Grep Console



[更新]
正如评论者所指出的:
在当前最新版本的Eclipse中安装Grep Console时,需要取消选中按类别分组安装对话框以查看可用的项目。



[更新2]
如azdev所指出,要正确突出显示


只输入文字字符串不起作用。要得到一条颜色的线条,您必须在两边的
。*
中包含字符串,如下所示:
。* ERROR。*



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 in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed the colors in the string to have it colored in the logs.

It sure would help making the important bits stand out without resorting to weird layout, rather keep the layout to the log4j setups

here is an example of what I am looking for :

[INFO ] The grid is complete ....... false

where the bold parts would be in blue, this coloring can be controlled by the application to an extent. like so (tags are conceptual and arbitrary, but you get the idea):

log.info(String.format("The grid is complete ....... <blue>%s</blue>", isComplete ));


On a more general note it is the ability to embed meta information in the logs to help the presentation of these logs. Much like we tag web pages content to help the presentation of the information by CSS.

解决方案

have a try with this Eclipse Plugin: Grep Console

[UPDATE]: As pointed out by commenters: When installing Grep Console in the currently last version of Eclipse, you need to uncheck 'Group items by category' in the Install dialog to see the available items.

[UPDATE 2]: As pointed out by azdev, to get proper highlighting

entering just literal strings doesn't work. To get a line to be colored, you have to enclose the string in .* on either side, like so: .*ERROR.*

这篇关于在eclipse控制台中着色日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆