Class LogFormatter

    • Constructor Detail

      • LogFormatter

        public LogFormatter()
    • Method Detail

      • format

        public String format​(LogRecord record)
        Format the given LogRecord.

        The formatting can be customized by specifying the format string in the java.util.logging.SimpleFormatter.format property. The given LogRecord will be formatted as if by calling:

         String.format(format, date1, date2, source1, source2, method, line, logger, level1, level2, message, thread1, thread2, thrown);
         
        where the arguments are:
          • format - the java.util.Formatter format string specified in the corresponding format property or the default format.
          • date1 - Date/Time in "dd/MM/yyyy hh:mm:ss.SSS" format representing event time of the log record.
          • date2 - a Date object representing event time of the log record.
          • source1 - Full class name of the caller, if available.
          • source2 - Class name of the caller, if available.
          • method - Method name of the caller, if available.
          • line - Line number of the caller, if available.
          • logger - the logger's name.
          • level1 - the name of Level.
          • level2 - the localized name of Level.
          • message - the formatted log message returned from the Formatter.formatMessage(LogRecord) method. It uses java.text formatting and does not use the java.util.Formatter format argument.
          • thread1 - a unique Thread identifier
          • thread2 - the thread name
          • thrown - a string representing the throwable associated with the log record and its backtrace beginning with a newline character, if any; otherwise, an empty string
        Specified by:
        format in class Formatter
      • validateFormat

        private void validateFormat​(String f)
                             throws IllegalArgumentException
        This call allows to validate a format throwing an IllegalArgumentException if the format is not valid.
        Parameters:
        f - The format to validate.
        Throws:
        IllegalArgumentException - if the format is not valid.