Package org.objectweb.util.monolog.jul
Class LogFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- org.objectweb.util.monolog.jul.LogFormatter
-
- All Implemented Interfaces:
ExtendedFormatter
class LogFormatter extends Formatter implements ExtendedFormatter
-
-
Field Summary
Fields Modifier and Type Field Description private static StringDEFAULT_FORMATprivate static DateFormatdfprivate Stringformatprivate static StringFORMAT_PROP_KEYprivate static StringOLD_FORMAT_PROP_KEY
-
Constructor Summary
Constructors Constructor Description LogFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(LogRecord record)Format the given LogRecord.voidsetFormat(String f)private voidvalidateFormat(String f)This call allows to validate a format throwing an IllegalArgumentException if the format is not valid.-
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
-
-
-
Field Detail
-
FORMAT_PROP_KEY
private static final String FORMAT_PROP_KEY
- See Also:
- Constant Field Values
-
OLD_FORMAT_PROP_KEY
private static final String OLD_FORMAT_PROP_KEY
- See Also:
- Constant Field Values
-
DEFAULT_FORMAT
private static final String DEFAULT_FORMAT
- See Also:
- Constant Field Values
-
format
private String format
-
df
private static final DateFormat df
-
-
Method Detail
-
format
public String format(LogRecord record)
Format the given LogRecord.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:
where the arguments are:String.format(format, date1, date2, source1, source2, method, line, logger, level1, level2, message, thread1, thread2, thrown);
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 string
-
validateFormat
private void validateFormat(String f) throws IllegalArgumentException
This call allows to validate a format throwing an IllegalArgumentException if the format is not valid.- Parameters:
f- The format to validate.- Throws:
IllegalArgumentException- if the format is not valid.
-
setFormat
public void setFormat(String f) throws IllegalArgumentException
- Specified by:
setFormatin interfaceExtendedFormatter- Throws:
IllegalArgumentException
-
-