-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
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);
}
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);
}
- relates to
-
JDK-8012006 PlatformLogger needs improvement to avoid wrapping logging message with isLoggable check
-
- Open
-