RFR 2: JDK-8005263: Logging APIs takes Supplier<String> for message

Henry Jen henry.jen at oracle.com
Thu Dec 27 00:23:30 UTC 2012

On 12/22/2012 07:30 AM, Jason Mehrens wrote:
> The msg argument in most cases is a string literal because it is either
> a resource bundle key or a MessageFormat literal.  The established best
> practice is to convert on the fly construction of messages to use
> the MessageFormat syle logging.  This current patch is kind of
> anti-pattern of that practice.  I would think the real win would be to
> delay construction of the 'params' argument in the logging framework. 
> Allowing the callers to write logger.log(level, "{0}", Foo::bar) and
> have the call to bar be lazy eval would be the best of both the logging
> world and the lambda world.

For messages not just only for developer, they should be localized as
you suggested and in such cases, it is possible to achieve the laziness
via Object.toString(), less straightforward than using a lambda, but is


More information about the core-libs-dev mailing list