[LOGBack-user] Message Format question

Ceki Gülcü listid at qos.ch
Fri Sep 8 20:21:40 CEST 2006

Hello George,

We chose the {} format instead of the more common {0} for performance 
reasons. One can parse format string quicker when there is no need to worry 
about order. Moreover, it is a *little* easier on the fingers to write

   logger.debug("hello {}", name);

than to write

  logger.debug("hello {0}", name);

There is also a higher risk making mistakes with the common, i.e. {0}, 
format. For example,

  logger.debug("hello {O}", name);
  logger.debug("hello {1}", name);
  logger.debug("hello {1}, I am {0}", yourName, myName);

are all wrong. 'O' instead of '0', '1' instead of '0' and '1,0' instead of 

In short, we chose to optimize for the most common case by sacrificing less 
common usage patterns.

As you say, the issue was debated previously, for example see:


Does this answer your question properly?

At 03:23 PM 9/8/2006, Harp, George wrote:
>I have just started to explore logback and currently use log4j.
>My first newb question has to do with the formating of messages chosen 
>(not critisizm)
>logger.errror( "this is an errr {} {}", new Object(), new Object{});
>My not use the i18n syntax so log messages can be internationalized?
>logger.error("this is err {0} (1}, new Object(), new Object());
>then the first arguement can be read from properties files or db fro the 
>curent locale and be changable accordimng to lanhuage needs.
>I have a feeling that ths was discussed already and I will be hearing the 
>results of that discussion.
>Thanks for starting this project i do like the idea and plan to use it in 
>an upcoming project that I am involved in.

Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.

More information about the Logback-user mailing list