[logback-user] Customize how some objects are "printed"

Blaise Gervais gervais.b at gmail.com
Tue Jun 19 13:47:50 CEST 2012

Hi everyone,

We are used to log the current user. But the current user is a complex
object with a ugly "toString()" who print many unuseful informations with
new lines. And, of course, we can't override that.
To have clean logs, we have to walk into the user object structure until
relevant informations and deal with many possibles null pointers.

My question is : Is it a way to register something usable by SLF4J to
render an object to a String ?

Something like :

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

    *<renderer class="com.our.company.logging.UserContextRenderer" **/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120619/4430434e/attachment.html>

More information about the Logback-user mailing list