public class CompactFormatter extends Formatter
alternate
fixed width format.
The LogManager properties are:
format
string used to transform the output. The format string can be used to
fix the output size. (defaults to "%7$#.160s%n")Constructor and Description |
---|
CompactFormatter()
Creates an instance with a default format pattern.
|
CompactFormatter(String format)
Creates an instance with the given format pattern.
|
Modifier and Type | Method and Description |
---|---|
protected Throwable |
apply(Throwable t)
Chooses a single throwable from the cause chain that will be formatted.
|
String |
format(LogRecord record)
Format the given log record and returns the formatted string.
|
String |
formatBackTrace(LogRecord record)
Formats the back trace for the given log record.
|
String |
formatLevel(LogRecord record)
Formats the level property of the given log record.
|
String |
formatLoggerName(LogRecord record)
Formats the logger name property of the given log record.
|
String |
formatMessage(LogRecord record)
Formats message for the log record.
|
String |
formatMessage(Throwable t)
Formats the message from the thrown property of the log record.
|
String |
formatSource(LogRecord record)
Formats the source from the given log record.
|
String |
formatThrown(LogRecord record)
Formats the thrown property of a LogRecord.
|
protected boolean |
ignore(StackTraceElement s)
Determines if a stack frame should be ignored as the cause of an error.
|
protected String |
toAlternate(String s)
Defines the alternate format.
|
public CompactFormatter()
public String format(LogRecord record)
java.util
argument indexes are assigned to the following properties:
format
- the java.util.Formatter
format string specified in the
<formatter-name>.format property or the format that was given when
this formatter was created.date
- a Date
object representing
event time of the log record.source
- a string representing the caller, if available;
otherwise, the logger's name.logger
- the logger's name.level
- the
log level.message
- the formatted log message returned from the
formatMessage(LogRecord)
method.thrown
- a string representing the
throwable associated with the log record
and a relevant stack trace element if available. Otherwise, an empty
string is used.message|thrown
The message and the thrown properties joined
as one parameter. This parameter supports
alternate
form.thrown|message
The thrown and message properties joined as
one parameter. This parameter supports
alternate
form.format
in class Formatter
record
- to format.NullPointerException
- if the given record is null.public String formatMessage(LogRecord record)
formatMessage
in class Formatter
record
- the log record.public String formatMessage(Throwable t)
t
- the throwable to format.public String formatLevel(LogRecord record)
record
- the record.NullPointerException
- if the given record is null.public String formatSource(LogRecord record)
record
- the record.NullPointerException
- if the given record is null.public String formatLoggerName(LogRecord record)
record
- the record.NullPointerException
- if the given record is null.public String formatThrown(LogRecord record)
record
- the record.NullPointerException
- if the given record is null.apply(java.lang.Throwable)
,
formatBackTrace(java.util.logging.LogRecord)
public String formatBackTrace(LogRecord record)
record
- the log record to format.NullPointerException
- if the given record is null.apply(java.lang.Throwable)
,
formatThrown(java.util.logging.LogRecord)
,
ignore(java.lang.StackTraceElement)
protected Throwable apply(Throwable t)
t
- the throwable from the log record.formatThrown(java.util.logging.LogRecord)
protected boolean ignore(StackTraceElement s)
s
- the stack trace element.formatThrown(java.util.logging.LogRecord)
Copyright © 2020 Oracle. All rights reserved.