[hibernate-dev] on broken usage of logger

Sanne Grinovero sanne at hibernate.org
Wed Nov 23 05:34:29 EST 2011

Hi all,
I'm having a chat with Hardy about how we used the Logger in some
cases, and it turns out there's some confusion about

  log.debugf   vs   log.debug
  log.tracef     vs   log.trace

So the "F" variant is needed when we want to format a message, in this
case we should make sure the number of parameters matches exactly.

Also when the string is generated, like in the case of:


it's very important that we do NOT use the formatting method, but just
a plain "log.debug( string )", otherwise it might happen at runtime
that the dynamically generated string contains some characters which
the String formatter might want interpret as placeholders, which are
missing. (HHH-6817)

In practice, it seems like a bad idea to allow a dynamically generated
formatting string at all; formatting strings as defined on the Logger
interface are safer;

In case a dynamically generated message is to be generated, we should
all make sure to pick the correct method signature; we're wondering if
there could be a reasonable proposal to make the checks of the
annotation processor stricter and validate for this, but there are
some (rare) valid use cases so just throwing compilation errors would
be nasty.


More information about the hibernate-dev mailing list