public class PrintfFormatter extends Formatter
Formatter that formats a LogRecord through a format string (as described for Formatter) which is specified through the de.unkrig.commons.util.logging.FormatFormatter.format
 logging property.
 
 Notice:
 Since Java 7, the SimpleFormatter also has a '.format' property and thus implements the
 key feature of this class.
 
 This class is a COPY of de.unkrig.ext.logging.formatter.PrintfFormatter, and should be kept in sync
 with that.
| Modifier and Type | Field and Description | 
|---|---|
| static PrintfFormatter | BENCHMARKFormats log records with the format string ""%12$s %10$-20s %3$2d %8$s%n"", which is very suitable for
 benchmarking. | 
| static PrintfFormatter | COMPACTFormats log records with the format string ""%4$s %6$s::%7$s %8$s%9$s%n"", which produces a rather
 terse logging format. | 
| static PrintfFormatter | DEFAULTThe "default formatter", which is  SIMPLE. | 
| static String | FORMAT_STRING_BENCHMARK | 
| static String | FORMAT_STRING_COMPACT | 
| static String | FORMAT_STRING_MESSAGE | 
| static String | FORMAT_STRING_MESSAGE_AND_EXCEPTION | 
| static String | FORMAT_STRING_MESSAGE_AND_STACK_TRACE | 
| static String | FORMAT_STRING_SIMPLE | 
| static String | FORMAT_STRING_TIME_MESSAGE | 
| static PrintfFormatter | MESSAGEFormats log records with the format string "%8$s%n" (which expands to the log message). | 
| static PrintfFormatter | MESSAGE_AND_EXCEPTIONFormats log records with the format string "%8$s%11$s%n" (which expands to the
 log message plus the (optional) exception name and message). | 
| static PrintfFormatter | MESSAGE_AND_STACK_TRACEFormats log records with the format string "%8$s%9$s%n" (which expands to the
 log message, plus the (optional) exception name, message and stack trace). | 
| static PrintfFormatter | SIMPLEFormats log records with the format string "%5$tF %5$tT.%5$tL %10$-20s %3$2d %8$s%9$s%n" (which produces a simple one-line
 format with date, time, simple class name, thread id, log message and the (optional) stack trace). | 
| static PrintfFormatter | TIME_MESSAGEFormats log records with the format string "%5$tF %5$tT.%5$tL %8$s%n" (which produces a simple
 one-line format with date, time and log message). | 
| Modifier | Constructor and Description | 
|---|---|
|   | PrintfFormatter()The format string is retrieved from the  "de.unkrig.commons.util.logging.formatter.PrintfFormatter.format"logging property. | 
| protected  | PrintfFormatter(int dummy,
               String propertyNamePrefix)Constructor for derived classes which wish to impose a different ".format" logging property than that used
 by  PrintfFormatter(). | 
|   | PrintfFormatter(String format)A format string with placeholders as described for  format(LogRecord). | 
| Modifier and Type | Method and Description | 
|---|---|
| String | format(LogRecord record)Formats a  LogRecordwith a PRINTF format string. | 
| String | getFormat() | 
| void | setFormat(String format)Sets the format string for this logger. | 
formatMessage, getHead, getTailpublic static final String FORMAT_STRING_BENCHMARK
public static final String FORMAT_STRING_COMPACT
public static final String FORMAT_STRING_MESSAGE
public static final String FORMAT_STRING_MESSAGE_AND_EXCEPTION
public static final String FORMAT_STRING_MESSAGE_AND_STACK_TRACE
public static final String FORMAT_STRING_SIMPLE
public static final String FORMAT_STRING_TIME_MESSAGE
public static final PrintfFormatter BENCHMARK
Example:
     3.000000;    2.000000;    1.000000 MyClass               0 Message
 public static final PrintfFormatter COMPACT
Examples:
 FINE pkg.MyClass::main Log message #1
 FINE pkg.MyClass::main Log message #2
 java.io.IOException: Exception message
     at pkg.MyClass.main()
 format(LogRecord)public static final PrintfFormatter MESSAGE
Example:
Log message
format(LogRecord)public static final PrintfFormatter MESSAGE_AND_EXCEPTION
Examples:
Log message Log message: java.io.FileNotFoundException: Exception message
format(LogRecord)public static final PrintfFormatter MESSAGE_AND_STACK_TRACE
Examples:
 Log message #1
 Log message #2
 java.io.IOException: Exception message
     at pkg.MyClass.main()
 format(LogRecord)public static final PrintfFormatter SIMPLE
Example:
 2012-03-08 10:10:28.515 MyClass               0 Log message #1
 2012-03-08 10:10:28.516 MyClass               0 Log message #2
 java.io.IOException: Exception message
     at pkg.MyClass.main()
 format(LogRecord)public static final PrintfFormatter TIME_MESSAGE
Example:
2012-12-31 23:59:59.999 Message
public static final PrintfFormatter DEFAULT
SIMPLE.public PrintfFormatter()
"de.unkrig.commons.util.logging.formatter.PrintfFormatter.format"
 logging property.
 
   Logging properties are typically defined in the file "$JAVA_HOME/jre/lib/logging.properties".
 
LogManager, 
Loggerprotected PrintfFormatter(int dummy,
                          @Nullable
                          String propertyNamePrefix)
PrintfFormatter().dummy - Only there to distinguish this constructor from PrintfFormatter(String)propertyNamePrefix - The property name prefix, or null to use the qualified name of the
                           actual formatter classformat(LogRecord)public PrintfFormatter(String format)
format(LogRecord).
 The following special format strings are recognized:
format(LogRecord)public final void setFormat(String format)
The following special format string values designate certain "predefined" formats:
public String getFormat()
public String format(@Nullable LogRecord record)
LogRecord with a PRINTF format string.
 | Placeholder | Description | Example | 
|---|---|---|
| %1$d | Sequence number | |
| %2$s | Logger name | |
| %3$d | Thread ID | 1 | 
| %4$s | Level | FINE | 
| %5$tF %5$tT.%5$tL | Date/time | 2012-03-08 10:10:28.468 | 
| %6$s | Source class name | pkg.MyClass | 
| %7$s | Source method name | main | 
| %8$s | Message | |
| %9$s | The empty string iff the log record contains no throwable, otherwise: 
 | 
         preceding-text: | 
| %10$s | Simple source class name | MyClass | 
| %11$s | Colon, space, throwable converted to string (typically class name, colon, space, localized message) | 
         preceding-text: pkg.MyEception
        | 
| %12$s | Real, CPU and user time in milliseconds since this thread last logged to this handler | 3.000000; 2.000000; 1.000000 | 
| %n | Line separator | |
| %% | Percent character ('%') | 
Copyright © 2018 Arno Unkrig. All rights reserved.