[slf4j-user] Message format - change from '{}' to '%s'

Newcomb, Michael-P57487 Michael.Newcomb at gdc4s.com
Tue Nov 21 20:01:38 CET 2006


 Wanted to bring this back up because there was never any answer/comments from the SLF4J folks...

-----Original Message-----
From: user-bounces at slf4j.org [mailto:user-bounces at slf4j.org] On Behalf Of Newcomb, Michael-P57487
Sent: Friday, November 10, 2006 7:58 PM
To: User list for the slf4j project
Subject: Re: [slf4j-user] Message format - change from '{}' to '%s'

Yes.

And, you would just have to call String.format() to format the message:

debug(String format, Object... args)
{
  if (isDebugEnabled())
  {
    String text = String.format(format, args);

    impl.log(text); // or whatever...
  }
} 

You could still support the old format with a property or something, but I think moving to the format used by String.format() would be better than switching back and forth:

String fullyQualifiedName = String.format("%s.%s", packageName, className); log.debug("fullyQualifiedName = {}", fullyQualifiedName);

Thanks,
Michael

-----Original Message-----
From: user-bounces at slf4j.org [mailto:user-bounces at slf4j.org] On Behalf Of Martin Gilday
Sent: Friday, November 10, 2006 5:18 PM
To: User list for the slf4j project
Subject: Re: [slf4j-user] Message format - change from '{}' to '%s'

I assume he means like the java 5 System.out.printf.  This would be a more complex than the current system, but you gain the power of being able to format and reuse fields (as they are indexed) within your logging statement.  This would take the varargs addition to the next level.


----- Original message -----
From: "Ceki Gülcü" <listid at qos.ch>
To: "User list for the slf4j project" <user at slf4j.org>
Date: Fri, 10 Nov 2006 22:41:41 +0100
Subject: Re: [slf4j-user] Message format - change from '{}' to '%s'

At 02:44 PM 11/10/2006, you wrote:

>As SLF4J moves to Java 5, I would suggest you also change from using '{}' 
>to the formatted string style '%s' etc&#8230;

Hi Michael,

Would you care to expand on the question?

>Thanks,
>Michael

--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

_______________________________________________
user mailing list
user at slf4j.org
http://www.slf4j.org/mailman/listinfo/user
_______________________________________________
user mailing list
user at slf4j.org
http://www.slf4j.org/mailman/listinfo/user
_______________________________________________
user mailing list
user at slf4j.org
http://www.slf4j.org/mailman/listinfo/user



More information about the slf4j-user mailing list