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

Improve logging documentation to advice performance consideration

XMLWordPrintable

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

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

              Created:
              Updated: