|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.logging.Formatter
bb.util.logging.FormatterFull
public class FormatterFull
Like XMLFormatter
, this class uses almost all of the information in a LogRecord
in its output
and is ideal for a FileHandler to use.
It differs in that it uses a plain text form, instead of xml, so that it is more human readable
(e.g. by some operator pouring thru log files).
See format
for details.
The FormatterFull.Parser
inner class may be used to parse LogRecords from text
which was generated from LogRecords formatted by this class.
For example, this could be used by a program to analyse log files.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Nested Class Summary | |
---|---|
static class |
FormatterFull.Parser
Class which parses LogRecord s from data generated by format . |
static class |
FormatterFull.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private static String |
entrySeparator
|
private static String |
spacer
|
Constructor Summary | |
---|---|
FormatterFull()
|
Method Summary | |
---|---|
String |
format(LogRecord record)
Formats record into a String that looks like:
--------------------------------------------------
level seq#sss date thread#ttt className.methodName
[optional message, with any localization and param substitution applied]
[optional Throwable; first line is its class name and message, followed by its stack trace]
Notes:
sss is record's sequence number, which uniquely identifies it
among every LogRecord known by LogManager
ttt is record's int thread ID value
if the optional message is present, then localization and param substitution are perfomed by a call to formatMessage (record)
a newline is always appended to the message if it is non-null, so the user need not add this
This format was chosen for several reasons. |
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 |
---|
private static final String entrySeparator
private static final String spacer
Constructor Detail |
---|
public FormatterFull()
Method Detail |
---|
public String format(LogRecord record) throws IllegalArgumentException
--------------------------------------------------
level seq#sss date thread#ttt className.methodName
[optional message, with any localization and param substitution applied]
[optional Throwable; first line is its class name and message, followed by its stack trace]
Notes:
sss
is record's sequence number, which uniquely identifies it
among every LogRecord known by LogManager
ttt
is record's int thread ID valueformatMessage
(record)newline
is always appended to the message if it is non-null, so the user need not add thisThis format was chosen for several reasons. First, it contains all the useful information: every "get" method of record is used except for getLoggerName and getResourceBundleName. Second, it has a logical, top down order: all the metadata is in the top row, followed by the actual data (message and Throwable). Third, its compact form minimizes the number of lines. Fourth, the dashed separator visually delimits LogRecords, making it easier for a human reader to parse the logs
format
in class Formatter
record
- the LogRecord to be formatted; must not be null
IllegalArgumentException
- if record == null; if record's message, after formatting, contains entrySeparator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |