JDK-8011635 : Improve logging documentation to advice performance consideration
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.logging
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-04-05
  • Updated: 2013-04-12
Related Reports
Relates :  
Description
Improve logging documentation w.r.t. the performance advices from Laurent Bourges:

Bad practices:
- string concat:
    log.fine("message" + value); // means StringBuilder(message).append(String.valueOf(value)).toString(): 2 objects created and value.toString() called
- varags:
    log.fine("message {0}", this); // create an Object[]

Best practices:
if (log.isLoggable(PlatformLogger.FINE) {
    log.fine("message" + value);
}

if (log.isLoggable(PlatformLogger.FINE) {
    log.fine("message {0}", this);
}