[prev in list] [next in list] [prev in thread] [next in thread] 

List:       logback-user
Subject:    [logback-user] Customize how some objects are "printed"
From:       Blaise Gervais <gervais.b () gmail ! com>
Date:       2012-06-19 11:47:50
Message-ID: CAEY7XjnoRREBvV8QByNPnwLM4fJrkg5hnv4go5L-Qm8YbM7HFQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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" **/>*
</appender>

[Attachment #5 (text/html)]

Hi everyone,<div><br></div><div>We are used to log the current user. But the current \
user is a complex object with a ugly &quot;toString()&quot; who print many unuseful \
informations with new lines. And, of course, we can&#39;t override that.</div>

<div>To have clean logs, we have to walk into the user object structure until \
relevant informations and deal with many possibles null \
pointers.</div><div><br></div><div>My question is : Is it a way to register something \
usable by SLF4J to render an object to a String ?</div>

<div><br></div><div>Something like :</div><div><pre id="sampleLayoutConfig" \
class="prettyprint source" \
style="padding:2px;margin-top:0px;margin-bottom:0px;background-color:rgb(245,245,245);font-family:Courier,&#39;MS \
Courier New&#39;,Prestige,monospace;border-top-width:1px;border-top-style:solid;border \
-top-color:rgb(136,136,136);border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(136,136,136);line-height:20px;font-size:medium">


<span class="tag" style="color:rgb(0,0,136)">&lt;appender</span><span class="pln"> \
</span><span class="atn" style="color:rgb(102,0,102)">name</span><span class="pun" \
style="color:rgb(102,102,0)">=</span><span class="atv" \
style="color:rgb(0,136,0)">&quot;STDOUT&quot;</span><span class="pln"> </span><span \
class="atn" style="color:rgb(102,0,102)">class</span><span class="pun" \
style="color:rgb(102,102,0)">=</span><span class="atv" \
style="color:rgb(0,136,0)">&quot;ch.qos.logback.core.ConsoleAppender&quot;</span><span \
class="tag" style="color:rgb(0,0,136)">&gt;</span><span class="pln"><br>

    </span><b><span class="tag" style="color:rgb(0,0,136)">&lt;renderer </span><span \
class="atn" style="color:rgb(102,0,102)">class</span><span class="pun" \
style="color:rgb(102,102,0)">=</span><span class="atv" \
style="color:rgb(0,136,0)">&quot;com.our.company.logging.UserContextRenderer&quot; \
</span></b><b><span class="tag" style="color:rgb(0,0,136)">/&gt;</span></b><span \
class="pln"><br>

</span><span class="tag" \
style="color:rgb(0,0,136)">&lt;/appender&gt;</span></pre><div><br></div> </div>



_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic