Ceki Gulcu wrote:<br>&gt; Ralph Goers wrote:<br>&gt;&gt;<br>&gt;&gt; I don&#39;t take offense at technical discussions on mailing lists. A lot can get misinterpreted.<br>Good to hear.<br>&gt;&gt; Instead, I suggest you take a look at the code and see if you think it is a horrible idea.  <br>
I will, but not right now. I&#39;m pretty sure it&#39;s not a horrible idea, though ;)<br>&gt;&gt; What I&#39;m currently actually using, but would replace with this, does have more knowledge of Logback, specifically so it can pass the objects to the Appender. Unfortunately (at least I think so), SLF4J&#39;s LocationAwareLogger doesn&#39;t provide a method to pass that information along.<br>
&gt;<br>&gt; I was meaning to ask. Why do you need support from LocationAwareLogger for argument arrays if you are going to use logback-classic underneath SLF4J?<br>&gt;<br>&gt;&gt; I assume an NDC is based on a ThreadLocal? This works well for data that lasts the lifetime of the request in progress. It is dangerous to use for data for a specific event as that data must be cleared after the event is completed - without disturbing other data that might have been stored in it.<br>
&gt;<br>&gt; Precisely. If push comes to shove, referring to my previous example using object of type &quot;Article&quot;, we could write<br>&gt;<br>&gt; MDC.put(&quot;article&quot;, article); // push data<br>&gt; <a href="http://logger.info">logger.info</a>(&quot;article modified&quot;);<br>
&gt; MDC.remove(&quot;article&quot;);  // mandatory clean up<br>&gt;<br>&gt; However, this is less convenient than writing,<br>&gt;<br>&gt; <a href="http://logger.info">logger.info</a>(&quot;article modified&quot;, article);<br>
&gt;<br>&gt; Note the lack of an anchor in the message. This is to emphasize that<br>&gt; we are using the argumentArray as an extension point, circumventing<br>&gt; usual message formatting. It is the responsibility of<br>
&gt; &quot;article&quot;-specific appenders to process articles.  This is similar to<br>&gt; the way MDC data is not always necessarily printed. In the previous<br>&gt; example, we are using the MDC as an extension point, albeit a clumsy<br>
&gt; one.<br>&gt;<br>Using Ralphs example:<br>logger.logEvent(EventData data)<br><br>Wouldn&#39;t it be possible to hide all that init and cleanup in the logEvent method?<br>e.g. something like the following<br>void logEvent(EventData data) {<br>
   EventDataHolder.set(data);<br>   info(&quot;whatever&quot;);<br>   EventDataHolder.reset();<br>}<br><br>That way, a special appender could access the EventData from the ThreadLocal storage... assuming that it is executed synchronously... but I guess that guaranteed delivery mandates synchronous handling anyway, right?<br>
<br>&gt;&gt; Ralph<br>Joern.<br><br>(gmail is completely snafud at the moment...)<br>