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

Logging methods should use varargs for format params

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • None

      Many Logging API methods take an Object[] argument for a list of parameters to apply to some format. E.g.

      http://download.java.net/jdk6/docs/api/java/util/logging/Logger.html#log(java.util.logging.Level,%20java.lang.String,%20java.lang.Object[])

      or

      http://download.java.net/jdk6/docs/api/java/util/logging/LogRecord.html#setParameters(java.lang.Object[])

      It would be more convenient for these to use varargs syntax. E.g. for a message key like:

      ERR-file-not-found=File {0} was not found in the directory {1}.

      you currently have to write:

      File f = ...;
      logger.log(Level.WARNING, "ERR-file-not-found", new Object[] {f.getName(), f.getParentPath()});

      where this would be more pleasant:

      logger.log(Level.WARNING, "ERR-file-not-found", f.getName(), f.getParentPath());

      Compare

      http://download.java.net/jdk6/docs/api/java/text/MessageFormat.html#format(java.lang.String,%20java.lang.Object...)

            Unassigned Unassigned
            jglick Jesse Glick (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: