4

I once had a link to a blog that showed how to configure Logback in the logback.xml file so that warn and severe level show up in red and other levels show up in black in the Eclipse console.

I can't seem to hit Google right now (Bing seems to be working) because of some company firewall issues. Anyone have a link to how to do that?

Lii
  • 9,906
  • 6
  • 53
  • 73
Dean Hiller
  • 17,183
  • 19
  • 103
  • 176

4 Answers4

4

You have to configure logback to log to stderr. Eclipse will display those lines in red.

But I strongly recommend you use the Grep Console Plugin:

Grep Console allows you to define a series of regular expressions which will be tested against the console output. Each expression matching a line will affect the style of either the entire line or parts of it. For example, error messages could be set to show up with a red background, or integer values showing the state of a certain variable could be rendered in bold font.

The advantage of this plugin is that you can highlight different log levels in different colors. I also highlight lines in stacktraces which belong to my classes. This makes finding the relevant lines in stacktraces much easier.

Screenshot

Christoph Leiter
  • 8,627
  • 3
  • 27
  • 37
  • thanks, was close enough that I googled stderr,stdout as I forgot about that..found the answer and posted the link. – Dean Hiller Nov 01 '12 at 14:50
  • The default regular expressions don't work for logback. What did you do to make it all work? – Stephane Grenier Feb 10 '13 at 03:49
  • @StephaneGrenier: I think what you're getting is that the default expressions are expecting log levels in square brackets ("[DEBUG]", "[WARNING]", etc.), whereas many appender configurations would use something like `%-5level` without square brackets. So either adjust the regex and remove the square brackets (and shorten "WARNING" to "WARN"), or adjust your appender pattern to output square brackets. – Amos M. Carpenter Apr 30 '14 at 00:17
1

Have you seen the relevant logback documentation.

Ceki
  • 24,295
  • 7
  • 57
  • 71
  • You will need an Eclipse console plugin for that feature to work instead of printing out ANSI code garbage. https://stackoverflow.com/questions/6286701/an-eclipse-console-view-that-respects-ansi-color-codes – Noumenon Mar 15 '20 at 16:55
1

Christopher's answer got me there...found what I was looking for...

How can I configure Logback to log different levels for a logger to different destinations?

so any developers that join the team don't need an eclipse plugin and it works great!!!

Community
  • 1
  • 1
Dean Hiller
  • 17,183
  • 19
  • 103
  • 176
0

You might also want to check out Beagle: http://logback.qos.ch/beagle/

Stephane Grenier
  • 14,426
  • 35
  • 98
  • 179