-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
7
-
None
To log a message, calling PlatformLogger.fine("...." + object) and PlatformLogger.fine("...", o1, o2) cause string concatenation and creation of Object[] passing as varargs that cause unnecessary overhead in the case when the message is not needed to be logged. This applies to all methods for logging a message (fine, finer, finest, etc). JDK classes log messages for debugging purpose that are lower level that INFO (the default level).
One way to mitigate this overhead, wrap the call with:
if (logger.isLoggable(FINE)) {
logger.fine(....);
}
Existing code also shows that it's easy to make a mistake in mismatched level in the isLoggable call vs the intended log message level.
We should look for any improvement in the API to help make the development easier and avoid this boilerplate.
One way to mitigate this overhead, wrap the call with:
if (logger.isLoggable(FINE)) {
logger.fine(....);
}
Existing code also shows that it's easy to make a mistake in mismatched level in the isLoggable call vs the intended log message level.
We should look for any improvement in the API to help make the development easier and avoid this boilerplate.
- relates to
-
JDK-8010297 Missing isLoggable() checks in logging code
-
- Resolved
-
-
JDK-8011635 Improve logging documentation to advice performance consideration
-
- Open
-