[logback-dev] MessageFormatter

ruediger.dohna at 1und1.de
Wed Jan 20 14:36:09 CET 2010

Hi Joern,

Joern Huxhorn-2 wrote:
> I'd be happy if you could take a few minutes and check out my proposal.

You where kidding, right?!? "a few minutes"... well, I still did take a
look. Nice proposal and it's good to know that there might be some things
like that coming. Passing your own Message instances into the API would be
powerful and definetely a gain. But I think that's not only an API change,
it's a completely different design. I'd say: That's a too big a step for
SLF4J to reasonably take. Why not put it into a separate structured logging
artifact that wrapps SLF4J. The impact on performance the wrapping will have
is probably in the same range a that you'd introduce by replacing e.g.
debug(msg, arg0) with debug(msg, new Object[] { arg0 }) by only using
varargs... hotspot is really smart, you know?

For the varargs discussion, I like Cekis suggestion 
http://bugzilla.slf4j.org/show_bug.cgi?id=31#c31 31-31  best.

> Changing the default message format (or making it configurable) of  
> Logback, on the other hand, isn't a good idea since the contract of it  
> is derived from SLF4J. Any SLF4J implementation must be able to  
> support the new formatting.

Your warning is legitimate! But I don't want to change the message format, I
want to change the formatter! I don't want to e.g. put extra stuff within
the curly bracket placeholders, generally preventing other SLF4J
implementations from working properly. But I do want to change what goes in
there. I.e. when I want to log a message with an argument that's an instance
of a class that doesn't override toString to my liking (most notably: not at
all), I want to provide my own formatter for all instances of that class.
Anything else would be my own risk... if I'd ever choose to go away from
logback, that is ;)

Put simply, your proposal requires the caller code to change (as well as
SLF4J, Logback, and many others) while my change would work with logging
calls from third party libraries as well ;-)

View this message in context: http://old.nabble.com/MessageFormatter-tp27209919p27241839.html
Sent from the Logback Dev mailing list archive at Nabble.com.

More information about the logback-dev mailing list