By default each CollectorFormatter is initialized using the following LogManager configuration properties where <formatter-name> refers to the fully qualified class name or the fully qualified derived class name of the formatter. If properties are not defined, or contain invalid values, then the specified default values are used.
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator | comparator
The comparator used to pick the log record to format. |
| private long | count
The number of log records that have been formatted. |
| private final String | fmt
The message format string used as the formatted output. |
| private final Formatter | formatter
The formatter used to format the chosen log record. |
| private long | generation
The number of log produced containing at least one log record. |
| private static final long | INIT_TIME
Avoid depending on JMX runtime bean to get the start time. |
| private LogRecord | last
The last accepted record. |
| private long | maxMillis
The newest log record time. |
| private long | minMillis
The eldest log record time or eldest time possible for this instance. |
| private long | thrown
The number of log records that have been formatted with a thrown object. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CollectorFormatter(String
the message format or null to use the LogManager default. format)Creates the formatter using the given format. |
| public | CollectorFormatter(String
the format string or null to use the LogManager default. format, Formatter the formatter used on the collected log record or null to
specify no formatter. f, Comparator<? super LogRecord> the comparator used to determine which log record to format or
null to specify no comparator. c)Creates the formatter using the given values. |
| Modifier and Type | Method and Description |
|---|---|
| private synchronized boolean | |
| private synchronized boolean | Returns: true if the update was performed.the expected record. e, LogRecord the update record. u)Updates the summary statistics and stores given LogRecord if the expected record matches the current record. |
| protected LogRecord | |
| protected String | |
| public String | Returns: an empty string.the record to store. record)Implements abstract java. |
| private String | Returns: the formatted string.the Handler or null. h, final boolean true if the summary statistics and LogRecord should be reset
back to initial values. reset)Formats the given record with the head and tail. |
| public String | Returns: the output string.the handler or null. h)Overrides java. |
| private Comparator | Returns: the comparator or null.the class name prefix. p)Gets and creates the comparator from the LogManager or returns the default comparator. |
| private String | Returns: the format string.the class name prefix. p)Gets the message format string from the LogManager or creates the default message format string. |
| private Formatter | Returns: the formatter.the class name prefix. p)Gets and creates the formatter from the LogManager or creates the default formatter. |
| private synchronized LogRecord | |
| private synchronized void | reset(final long
the current min milliseconds. min)Resets all of the collected summary statistics including the LogRecord. |
| public String | Returns: the current record formatted or the default toString.Overrides java. |
| comparator | back to summary |
|---|---|
| private final Comparator<? super LogRecord> comparator The comparator used to pick the log record to format. | |
| count | back to summary |
|---|---|
| private long count The number of log records that have been formatted. | |
| fmt | back to summary |
|---|---|
| private final String fmt The message format string used as the formatted output. | |
| formatter | back to summary |
|---|---|
| private final Formatter formatter The formatter used to format the chosen log record. | |
| generation | back to summary |
|---|---|
| private long generation The number of log produced containing at least one log record. Only incremented when this formatter is reset. | |
| INIT_TIME | back to summary |
|---|---|
| private static final long INIT_TIME Avoid depending on JMX runtime bean to get the start time. | |
| last | back to summary |
|---|---|
| private LogRecord last The last accepted record. Synchronized access is preferred over volatile for this class. | |
| maxMillis | back to summary |
|---|---|
| private long maxMillis The newest log record time. | |
| minMillis | back to summary |
|---|---|
| private long minMillis The eldest log record time or eldest time possible for this instance. | |
| thrown | back to summary |
|---|---|
| private long thrown The number of log records that have been formatted with a thrown object. | |
| CollectorFormatter | back to summary |
|---|---|
| public CollectorFormatter() Creates the formatter using the LogManager defaults.
| |
| CollectorFormatter | back to summary |
|---|---|
| public CollectorFormatter(String format) Creates the formatter using the given format.
| |
| CollectorFormatter | back to summary |
|---|---|
| public CollectorFormatter(String format, Formatter f, Comparator<? super LogRecord> c) Creates the formatter using the given values.
| |
| accept | back to summary |
|---|---|
| private synchronized boolean accept(final LogRecord e, final LogRecord u) Updates the summary statistics only if the expected record matches the last record. The update record is not stored.
| |
| acceptAndUpdate | back to summary |
|---|---|
| private synchronized boolean acceptAndUpdate(LogRecord e, LogRecord u) Updates the summary statistics and stores given LogRecord if the expected record matches the current record.
| |
| apply | back to summary |
|---|---|
| protected LogRecord apply(final LogRecord t, final LogRecord u) Used to choose the collected LogRecord. This implementation returns the greater of two LogRecords.
| |
| finish | back to summary |
|---|---|
| protected String finish(String s) Applied to the head, format, and tail returned by the target formatter. This implementation trims all input strings.
| |
| format | back to summary |
|---|---|
| public String format(final LogRecord record) Implements abstract java. Accumulates log records which will be used to produce the final output.
The output is generated using the
| |
| formatRecord | back to summary |
|---|---|
| private String formatRecord(final Handler h, final boolean reset) Formats the given record with the head and tail.
| |
| getTail | back to summary |
|---|---|
| public String getTail(final Handler h) Overrides java. Formats the collected LogRecord and summary statistics. The collected results are reset after calling this method. The java.text argument indexes are assigned to the following properties:
Some example formats:
| |
| initComparator | back to summary |
|---|---|
| private Comparator Gets and creates the comparator from the LogManager or returns the default comparator.
| |
| initFormat | back to summary |
|---|---|
| private String initFormat(final String p) Gets the message format string from the LogManager or creates the default message format string.
| |
| initFormatter | back to summary |
|---|---|
| private Formatter initFormatter(final String p) Gets and creates the formatter from the LogManager or creates the default formatter.
| |
| peek | back to summary |
|---|---|
| private synchronized LogRecord peek() Peek at the current log record.
| |
| reset | back to summary |
|---|---|
| private synchronized void reset(final long min) Resets all of the collected summary statistics including the LogRecord.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Formats the collected LogRecord and summary statistics. The LogRecord and summary statistics are not changed by calling this method.
| |