Alex Rivera | Logout

Formatting slf4j to log message types with colors

Asked 2012-09-17T22:51:10.150
23

I am using slf4j for logging in my Java Application. It involves a lot logging and log monitoring.
Sometimes it is really difficult to read and find information from logs when the entire log is printed in the black color with.
Just to make it more readable, is it possible to log the different kinds of messages in different colors?
For example all Error level messages in Red color or a different font size and all Info level messages in blue color and a different font size.

Any suggestions or help is welcome. Thnx.

Edit
Report

1 Answer

5

It's not possible to change colors of slf4j logging, because there are no formatters. SLF4J is a middleware between your application and some logging facility, for example, Log4j or Logback.

You can change colors in Log4j output, as explained here. I would recommend to use MulticolorLayout from jcabi-log

answered 2012-10-05T06:03:06.420

Your Answer