How to shorten thread name in logback logs?

Vladislav Rastrusny picture Vladislav Rastrusny · May 7, 2011 · Viewed 9.4k times · Source

You can shorten the name of the logger using %logger{x} syntax where x controls shortening procedure. Is there any way to shorten the name of the thread the same way?

Answer

broc.seib picture broc.seib · Mar 20, 2013
[%.7thread]

This will print the last 7 characters of the thread name.

Trailing characters of a thread name are often more interesting than the characters at the beginning of a thread name. :-)

You may read about the maximum field width modifier in the logback docs.