class LogFormatter extends Formatter implements ExtendedFormatter
Modifier and Type | Field and Description |
---|---|
private static String |
DEFAULT_FORMAT |
private static DateFormat |
df |
private String |
format |
private static String |
FORMAT_PROP_KEY |
private static String |
OLD_FORMAT_PROP_KEY |
Constructor and Description |
---|
LogFormatter() |
Modifier and Type | Method and Description |
---|---|
String |
format(LogRecord record)
Format the given LogRecord.
|
void |
setFormat(String f) |
private void |
validateFormat(String f) |
formatMessage, getHead, getTail
private static final String FORMAT_PROP_KEY
private static final String OLD_FORMAT_PROP_KEY
private static final String DEFAULT_FORMAT
private String format
private static final DateFormat df
public String format(LogRecord record)
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 identifierthread2
- the thread namethrown
- a string representing the throwable associated with the log record and its backtrace beginning
with a newline character, if any; otherwise, an empty stringprivate void validateFormat(String f) throws IllegalArgumentException
IllegalArgumentException
public void setFormat(String f) throws IllegalArgumentException
setFormat
in interface ExtendedFormatter
IllegalArgumentException
Copyright © 2023 ScalAgent D.T.. All rights reserved.