|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.logging.Formatter
de.unkrig.commons.util.logging.formatter.PrintfFormatter
public class PrintfFormatter
A 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.
| Field Summary | |
|---|---|
static PrintfFormatter |
BENCHMARK
A format for benchmarking: %12$s %10$-20s %3$2d %8$s%n Example: 3.000000; 2.000000; 1.000000 MyClass 0 Message |
static PrintfFormatter |
COMPACT
A compact one-line format: %4$s %6$s::%7$s %8$s%9$s%n Examples: FINE pkg.MyClass::main Log message #1 FINE pkg.MyClass::main Log message #2 java.io.IOException: Exception message at pkg.MyClass.main() |
static PrintfFormatter |
DEFAULT
The default format format PrintfFormatter(). |
static PrintfFormatter |
MESSAGE
%8$s%n Example: Log message |
static PrintfFormatter |
MESSAGE_AND_EXCEPTION
%8$s%n Examples: Log message Log message: java.io.FileNotFoundException: Exception message |
static PrintfFormatter |
MESSAGE_AND_STACK_TRACE
%8$s%9$s%n Examples: Log message #1 Log message #2 java.io.IOException: Exception message at pkg.MyClass.main() |
static PrintfFormatter |
SIMPLE
A simple one-line format: %5$tF %5$tT.%5$tL %10$-20s %3$2d %8$s%9$s%n 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() |
static PrintfFormatter |
TIME_MESSAGE
%5$tF %5$tT.%5$tL %8$s%n Example: 2012-12-31 23:59:59.999 Message |
| Constructor Summary | |
|---|---|
PrintfFormatter()
The format string is retrieved from the de.unkrig.commons.util.logging.formatter.PrintfFormatter.format
logging property. |
|
PrintfFormatter(java.lang.String propertyNamePrefix)
One-arg constructor for proxies. |
|
PrintfFormatter(java.lang.String format,
int dummy)
A format string with placeholders as described for format(LogRecord). |
|
| Method Summary | |
|---|---|
java.lang.String |
format(java.util.logging.LogRecord record)
Formats a LogRecord with a PRINTF format string. |
java.lang.String |
getFormat()
|
void |
setFormat(java.lang.String format)
|
| Methods inherited from class java.util.logging.Formatter |
|---|
formatMessage, getHead, getTail |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final PrintfFormatter COMPACT
FINE pkg.MyClass::main Log message #1
FINE pkg.MyClass::main Log message #2
java.io.IOException: Exception message
at pkg.MyClass.main()
public static final PrintfFormatter MESSAGE_AND_EXCEPTION
Log message Log message: java.io.FileNotFoundException: Exception message
public static final PrintfFormatter MESSAGE
Log message
public static final PrintfFormatter MESSAGE_AND_STACK_TRACE
Log message #1
Log message #2
java.io.IOException: Exception message
at pkg.MyClass.main()
public static final PrintfFormatter SIMPLE
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()
public static final PrintfFormatter TIME_MESSAGE
2012-12-31 23:59:59.999 Message
public static final PrintfFormatter BENCHMARK
3.000000; 2.000000; 1.000000 MyClass 0 Message
public static final PrintfFormatter DEFAULT
PrintfFormatter().
The default format is the SIMPLE.
| Constructor Detail |
|---|
public PrintfFormatter()
de.unkrig.commons.util.logging.formatter.PrintfFormatter.format
logging property.
Logging properties are typically defined in file $JAVA_HOME/jre/lib/logging.properties.
public PrintfFormatter(@Nullable
java.lang.String propertyNamePrefix)
format(LogRecord)
public PrintfFormatter(java.lang.String format,
int dummy)
format(LogRecord).
The following special format strings are recognized:
format(LogRecord)| Method Detail |
|---|
public final void setFormat(java.lang.String format)
format - null defines a default format.public java.lang.String getFormat()
public java.lang.String format(java.util.logging.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 | Colon, line break; type, message and stack trace (with no trailing line break) of the (optional) throwable |
preceeding-text:
|
| %10$s | Simple source class name | MyClass |
| %11$s | Colon, space, throwable converted to string (typically class name, colon, space, localized message) |
preceeding-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 ('%') |
format in class java.util.logging.Formatter
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||