[logback-dev] Layout setter/getter methods in AppenderBase
Ceki Gulcu
ceki at qos.ch
Mon Feb 9 23:15:04 CET 2009
Hello Joern,
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.)
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't use...
If the Appender interface did not contain the layout property, we would probably
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. Adding
UnsyncronizedAppenderBaseWithLayout would be too unwieldy. :-)
For developers coming from log4j, AppenderBase having the same implementation
for setLayout and getLayout as log4j's AppenderSkeleton class would help them
migrate to logback with a little bit more ease, at least with less surprise.
I wonder what I was thinking when I implemented layout setter and getters in
LayoutBase as nop.
Joern Huxhorn wrote:
> Hi Ceki,
>
> the only thing that I don't understand is why Appender requires a layout
> at all.
> 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.
> Some appenders, like SocketAppender or some fictitious appender that
> would simply serialize the events to a file (I'm planning to implement
> such an appender, btw), just don't need a layout at all.
> AppenderBase would then just implement the basic Appender interface,
> leaving the layout implementation to appenders that would really require
> it.
>
> This topic is covered by both http://jira.qos.ch/browse/LBCORE-1 and
> http://jira.qos.ch/browse/LBCORE-56
>
> Regards,
> Joern.
>
>
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the logback-dev
mailing list