How do I get Logback to work nicely with Eclipse?

江枫思渺然 提交于 2019-12-23 09:46:28

问题


How do I get my logging framework (currently Logback) to play nicely with Eclipse? In particular, it would be nice to click on a log statement and be taken to the line where it was produced.

I'm aware of the Logback Eclipse Plugin however apparently it is outdated, and only works with an old version of Logback.

Is there some other logging framework that works better with Eclipse? I assume there must be a nice way to do this.


回答1:


If you add %callerto the pattern, then the functionality of the Console of Eclipse can handle your problem...




回答2:


I use this pattern:

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

The (%file:%line) part is by default clickable in the Eclipse console.



来源:https://stackoverflow.com/questions/10131741/how-do-i-get-logback-to-work-nicely-with-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!