On Wed, Oct 10, 2012 at 2:19 AM, Ralph Goers <[email protected]>wrote:
> > On Oct 9, 2012, at 5:28 PM, Gary Gregory wrote: > > On Tue, Oct 9, 2012 at 10:19 AM, Ralph Goers > <[email protected]>wrote: > >> This requires a long answer. >> >> Ceki realized in Logback that OutputStreams really needed a byte array. >> So he changed Appenders to require an Encoder instead of an Appender. >> Layouts still return a String so he created a wrapper Encoder to convert >> the String to a byte array. >> >> The idea of using a byte array is correct - most of the time, as most of >> the Appenders use an OutputStream. However, the JMS appenders don't. They >> require a Serializable object. >> > >> When developing Log4j I did not like having both Encoders and Layouts, so >> I chose to have Layouts return a byte array. But then it made no sense to >> have something based on the AbstractStringLayout convert the String to a >> byte array only to have to convert it back to a String again for the JMS >> Appenders, which is why I added formatAs(). Now the JMS Appender can send >> both a Serialized LogEvent and a String. >> >> So in looking at how formatAs() is used I would think that we could just >> change Layout to >> >> public interface Layout { >> >> Serializable formatAs(); >> >> ... >> } >> >> OK, so we loose some type info, but that seems OK. > > While we are here, I think the format methods need better name especially > since there are two and formatAs(LogEvent) is not great, I keep on thinking > "format as... what?" A log event? No, that's what I pass in. What about > using the to* convention here? > > - byte[] toByteArray(LogEvent); > - Serializable toSerializable(LogEvent); > > > Yes - I like those names better. > I see you changed formatAs(LogEvent) to toSerialized(LogEvent) but I do not feel this is correct because the object has not been serialized, it has merely been converted into an object that *can be *serialized, hence my proposal for toSerializable(LogEvent), because the method returns a Serializable. Gary > Ralph > > -- E-Mail: [email protected] | [email protected] JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0 Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
