Hello,<br><br>I agree with Joern, it would be cleaner to have a LayoutAware interface, and only appenders that use a Layout should implement it. <br>The way it is now, people can set a layout on the SocketAppender, they don&#39;t get an exception, but the layout would never be used.<br>
<br>I can understand the &quot;historical&quot; reasons, but IMO things like this can be changed as long as logback doesn&#39;t reach 1.0Maarten<br><br>Related idea/proposal:&nbsp; an Encoder interface similar to Layout but returning a byte array instead of a String:<br>
<br>public interface Encoder {<br>&nbsp; byte[] encode(LoggingEvent event)<br>}<br><br>I recently worked on an AsyncSocketAppender (extending UnsyncronizedAppenderBase) and with this interface the wire-format would be pluggable.<br>
<br>Some wire-formats I am thinking about:&nbsp; Apache Thrift, Google protobuf and of course Java serialization.<br><br>I still have to implement these encoders and compare their perfomance.&nbsp; I will let you know when I get there.<br>
<br>It would be really cool if we could define a wire-format based on Protobuf and/or Thrift that could also be used for encoding log4j events.<br>But I guess it would be better to do this in a separate project ...<br><br>
regards,<br>Maarten<br><br><div class="gmail_quote">On Tue, Feb 10, 2009 at 1:01 AM, Joern Huxhorn <span dir="ltr">&lt;<a href="mailto:jhuxhorn@googlemail.com" target="_blank">jhuxhorn@googlemail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>
On 09.02.2009, at 23:15, Ceki Gulcu wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hello Joern,<br>
<br>
At an earlier time, certain classes expected the Appender interface to have a setter/getter for the layout property. AbstractLayoutAction is one such class. However, it is no longer used. (I just removed it.)<br>
<br>
</blockquote>
<br></div>
Oh, I see, &quot;for historic reasons&quot; :)<div><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Many logback appenders do not require a layout and can have their layout property set to null. Having a layout property in Appender and AppenderBase is just noise for such appenders but otherwise not harmful. They have a property, i.e. layout, which they don&#39;t use...<br>


</blockquote>
<br></div>
Well, yes, you are right. It&#39;s not downright harmful... but it is somewhat confusing for users (not developers) of the appenders and makes them wonder what the layout is about. People actually asked me about that...<div>

<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
If the Appender interface did not contain the layout property, we would probably &nbsp;have two distinct appender base implementations, AppenderBase and AppenderBaseWithLayout (possibly with an additional interface such as AppenderWithLayout). Come to think of it, we would also need to handle the UnsyncronizedAppenderBase branch of the class hierarchy. &nbsp;Adding UnsyncronizedAppenderBaseWithLayout would be too unwieldy. :-)<br>


<br>
</blockquote>
<br></div>
I don&#39;t think that this would be necessary because it would be enough if the mentioned classes would simply implement Appender (without the layout methods) and appenders requiring the layout would additionally implement the extended interface, in just the way that is necessary for their desired behavior (e.g. even synchronized/locked if required, which isn&#39;t the case right now).<br>


<br>
This is more or less an aesthetic reasoning and I wouldn&#39;t consider it very important.<br>
<br>
Concerning your original question: the new implementation is definitely better than before!<div><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For developers coming from log4j, AppenderBase having the same implementation for setLayout and getLayout as log4j&#39;s AppenderSkeleton class would help them migrate to logback with a little bit more ease, at least with less surprise.<br>


<br>
I wonder what I was thinking when I implemented layout setter and getters in LayoutBase as nop.<br>
</blockquote>
<br></div>
I know this feeling all too well...<br>
But this is actually a good thing because it&#39;s a sign that we keep developing our skills ;)<br><font color="#888888">
<br>
Joern.</font><div><div></div><div><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
<br>
Joern Huxhorn wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Ceki,<br>
the only thing that I don&#39;t understand is why Appender requires a layout at all.<br>
It would by cleaner if there was a sub-interface, e.g. LayoutAwareAooender (just a spontaneous suggestion), that extended Appender and would add said methods.<br>
Some appenders, like SocketAppender or some fictitious appender that would simply serialize the events to a file (I&#39;m planning to implement such an appender, btw), just don&#39;t need a layout at all.<br>
AppenderBase would then just implement the basic Appender interface, leaving the layout implementation to appenders that would really require it.<br>
This topic is covered by both <a href="http://jira.qos.ch/browse/LBCORE-1" target="_blank">http://jira.qos.ch/browse/LBCORE-1</a> and <a href="http://jira.qos.ch/browse/LBCORE-56" target="_blank">http://jira.qos.ch/browse/LBCORE-56</a><br>


Regards,<br>
Joern.<br>
</blockquote>
<br>
<br>
<br>
-- <br>
Ceki Gülcü<br>
Logback: The reliable, generic, fast and flexible logging framework for Java.<br>
<a href="http://logback.qos.ch" target="_blank">http://logback.qos.ch</a><br>
_______________________________________________<br>
logback-dev mailing list<br>
logback-dev@qos.ch<br>
<a href="http://qos.ch/mailman/listinfo/logback-dev" target="_blank">http://qos.ch/mailman/listinfo/logback-dev</a><br>
</blockquote>
<br>
_______________________________________________<br>
logback-dev mailing list<br>
logback-dev@qos.ch<br>
<a href="http://qos.ch/mailman/listinfo/logback-dev" target="_blank">http://qos.ch/mailman/listinfo/logback-dev</a><br>
</div></div></blockquote></div><br>