在eclipse中着色slf4j / log4j输出 [英] coloring slf4j/log4j output in eclipse

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

问题描述

我试图在eclipse / kepler(java)中使用logback-beagle。据我所知,目前不支持,如下所列(?)。

I am trying to use logback-beagle in eclipse/kepler (java). As I understand it is not currently supported as listed below(?).

http:// marketplace .eclipse.org / content / logback-beagle#.Uv1cGPldWK8

我仍然继续安装插件,不在windows-preferences下看到它。是否有替代方法可以获得类似的功能(颜色编码和在eclipse中从slf4j / log4j的日志输出导航)
或者我可以为eclipse(?)制作beagle插件。我不明白为什么eclipse想要在市场上拥有它,但在安装后没有出现在首选项中

I still went ahead and installed the plugin and dont see it under windows-preferences. Is there an alternative to get similar functionality (of color coding and navigating from log output of slf4j/log4j in eclipse) Or can I make beagle plugin work for eclipse(?). I dont understand why eclipse want to have it in marketplace, but doesnt show up in preferences after installing

推荐答案

我刚刚遇到过同样的问题,似乎logback-beagle根本不适用于kepler。我相信它适用于早期版本的eclipse,但遵循 http://logback.qos.ch/的安装说明。 beagle / 并尝试其他一些事情(例如用于记录的着色选项和JAnsi一起导致我无处可去。

I just came across the same issue, and it seems that logback-beagle simply does not work in kepler. I believe it works in earlier versions of eclipse but following the installation instructions from http://logback.qos.ch/beagle/ and trying a few other things (like the colouring options for logback with JAnsi) led me nowhere.

我找到的最好的选择(因为你要求一个)是 Grep Console ,它与我的kepler安装一起使用,并且非常易于配置,允许您在控制台输出上应用基于正则表达式的着色条件。

The best alternative I've found (since you asked for one) is Grep Console, which works with my kepler installation and is very configurable to allow you to apply regex-based colouring condtions on your console output.

至于你的从日志输出导航这一点,我假设你希望能够点击(Java)类名并自动导航到相应的类定义,您只需要配置控制台appender以包含outpu t代表文件和行号,即(%file:%line)(或%F %L 如果您愿意;有关详细信息,请参阅模式布局选项。例如,这是我在我的logback.xml文件中使用的内容:

As for your "navigating from log output" point, which I'm assuming means you want to be able to click on a (Java) class name and automagically navigate to the corresponding class definition, you simply need to configure your console appender to include the output for file and line number, i.e. (%file:%line) (or %F and %L if you prefer; see the pattern layout options for more details). For instance, here's what I'm using in my logback.xml file:

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%-5level %d{dd/MM/yyyy HH:mm:ss.SSS} \(%file:%line\) - %message%n</pattern>
    </encoder>
</appender>

使用Grep Console和文件行模式的唯一问题是Grep Console的样式行隐藏了类名和行号可点击的事实(Grep控制台样式覆盖了eclipse的链接的蓝色下划线)。我想如果你想要链接风格,你必须通过在Grep控制台中配置模式来识别这些链接并自己设置它们来解决它。

The only issue with using both Grep Console and the file-line-pattern is that the Grep Console's styling of lines hides the fact that the class name and line number is clickable (the Grep Console style overrides eclipse's blue underlining of the "link"). I guess if you want the "link style", you have to work around it by configuring a pattern in the Grep Console to recognise these links and style them yourself.

编辑:只是因为它让我没有看到链接的Java类,我使用以下模式来链接Java类和行号:

Just because it bugged me not to see the linked Java classes, I used the following pattern to "linkify" the Java classes and line numbers:

([a-zA-Z]+\.java:\d+)

我在管理表达式对话框中添加了一个表达式,称为Java链接,使用上面的正则表达式模式,并将其设置为不使用整行样式(即它将继承基于日志级别的样式)并将Group 1样式定义为蓝色(#0000ff)前景色和蓝色下划线,带有淡蓝色背景(#c0ffff),以便它将覆盖该行剩余部分的背景颜色:

I added an expression in the "Manage Expressions" dialog, called it "Java link", used the above regex pattern, and styled it to use no style for "Whole line" (i.e. it will inherit the style based on the log level) and defined "Group 1" style as blue (#0000ff) foreground colour and blue underlining, with a pale blue background (#c0ffff) so that it will override the background colour of the remainder of the line:

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

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