在 Eclipse 控制台中为日志着色

时间:2023-01-12
本文介绍了在 Eclipse 控制台中为日志着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

有没有办法在 Eclipse 控制台中为部分日志着色.我知道我可以发送到错误和标准流并为它们着色,但我更多的是在 ANSI 转义码(或任何其他,HTML?)的行中寻找一些东西,我可以在字符串中嵌入颜色以使其着色日志.

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.

这肯定有助于在不采用怪异布局的情况下突出重要部分,而是将布局保持在 log4j 设置中

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 ] 网格完成....... false

[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("网格完成....... <blue>%s</blue>",isComplete ));

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

更笼统地说,它可以在日志中嵌入元信息以帮助呈现这些日志.就像我们标记网页内容以帮助通过 CSS 呈现信息一样.

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.

推荐答案

试试这个 Eclipse 插件:Grep 控制台

Have a try with this Eclipse Plugin: Grep Console

[更新]:
正如评论者所指出的:在当前最新版本的 Eclipse 中安装 Grep Console 时,您需要在安装"对话框中取消选中按类别分组项目"以查看可用项目.
正如 @Line 所指出的,该插件现在可以通过以下方式轻松安装在不更改任何选项的情况下再次访问 Eclipse Marketplace.

[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.
As pointed out by @Line the plugin can now be easily installed via the Eclipse Marketplace again without changing any options.

[更新 2]:
正如 @azdev 所指出的,要获得正确的突出显示:

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

只输入文字字符串是行不通的.要使线条着色,您必须将字符串括在.*在任何一边,像这样:.*ERROR.*

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 控制台中为日志着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Java 中 System.out.println() 的字符限制 下一篇:Java中基于控制台的进度

相关文章

最新文章