public class LogEntryFormatter extends Formatter
Uses three simple parameter for configuring log entry formats:
dateFormat
- A SimpleDateFormat
string describing the format for dates.
format
- A string with {...}
replacement variables representing predefined fields.
useStackTraceHashes
- A setting that causes duplicate stack traces to be replaced with 8-character
hash strings.
This class converts the format strings into a regular expression that can be used to parse the resulting log file.
Constructor and Description |
---|
LogEntryFormatter(String format,
String dateFormat,
boolean useStackTraceHashes)
Create a new formatter.
|
Modifier and Type | Method and Description |
---|---|
String |
format(LogRecord r) |
DateFormat |
getDateFormat()
Returns the
DateFormat used for matching dates. |
String |
getField(String fieldName,
Matcher m)
Given a matcher that has matched the pattern specified by
getLogEntryPattern() , returns the field value
from the match. |
Pattern |
getLogEntryPattern()
Returns the regular expression pattern used for matching log entries.
|
formatMessage, getHead, getTail
public LogEntryFormatter(String format, String dateFormat, boolean useStackTraceHashes)
format
- The log entry format. e.g. dateFormat
- The SimpleDateFormat
format to use for dates. e.g. useStackTraceHashes
- If public Pattern getLogEntryPattern()
public DateFormat getDateFormat()
DateFormat
used for matching dates.DateFormat
used for matching dates.public String getField(String fieldName, Matcher m)
getLogEntryPattern()
, returns the field value
from the match.fieldName
- The field name.
Possible values are:
m
- The matcher.Copyright © 2018 Apache. All rights reserved.