Class TextFormatter


  • public class TextFormatter
    extends java.util.logging.Formatter
    A pattern-driven log formatter. Inspired by Log4j's PatternLayout Set a different output pattern with .format.

    The default format is "%5$tT %3$-5s %2$-20s :: %6$s\n".

    Examples:

    • "%5$tT.%5$tL %3$-5s %2$-20s :: %6$s\n" for milliseconds.
    • "%tF %5$tT.%5$tL %3$-5s %2$-20s :: %6$s\n" for date

    The log message formatting call is:

         String.format(format, 
                       loggerName,                        // 1
                       loggerNameShort,                   // 2
                       levelOutputName,                   // 3
                       Thread.currentThread().getName(),  // 4
                       new Date(record.getMillis()),      // 5
                       formatted$) ;                      // 6
     
    where formatted$ is the LogRecord message string after parameters have been processed.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextFormatter()  
      TextFormatter​(java.lang.String fmt)
      programmatic setup - provide the format
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(java.util.logging.LogRecord record)  
      • Methods inherited from class java.util.logging.Formatter

        formatMessage, getHead, getTail
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextFormatter

        public TextFormatter()
      • TextFormatter

        public TextFormatter​(java.lang.String fmt)
        programmatic setup - provide the format
    • Method Detail

      • format

        public java.lang.String format​(java.util.logging.LogRecord record)
        Specified by:
        format in class java.util.logging.Formatter