Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8012006

PlatformLogger needs improvement to avoid wrapping logging message with isLoggable check

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • 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.

            Unassigned Unassigned
            mchung Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: