Answer the question
In order to leave comments, you need to log in
Logback: how to format a message?
Hello! I use slf4g + Logback.
There is a code that displays the log: logger.info("{} {} {}", arg1, arg2, arg3)
I want it to be displayed as if in columns:
2017-10-20 15:18:58 INFO test.TestApp - 0 aaaaaa 2
2017-10-20 15:18:58 INFO test.TestApp - 123 ss 2
2017-10-20 15:18:58 INFO test.TestApp - 99 dddddddd 2
Answer the question
In order to leave comments, you need to log in
slf4j has a very simple formatter that only knows how to substitute values into anchors in line order. If you need complex formatting, then you will have to use a more functional, but also slower Java formatter:
logger.info(String.format("%-20s %-20s %-2d", arg1, arg2, arg3));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question