Class LogEntryFormatter
java.lang.Object
java.util.logging.Formatter
org.apache.juneau.microservice.resources.LogEntryFormatter
Log entry formatter.
Uses three simple parameter for configuring log entry formats:
-
dateFormat - ASimpleDateFormatstring 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 Summary
ConstructorsConstructorDescriptionLogEntryFormatter(String format, String dateFormat, boolean useStackTraceHashes) Create a new formatter. -
Method Summary
Modifier and TypeMethodDescriptionReturns theDateFormatused for matching dates.Given a matcher that has matched the pattern specified bygetLogEntryPattern(), returns the field value from the match.Returns the regular expression pattern used for matching log entries.Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
Constructor Details
-
LogEntryFormatter
Create a new formatter.- Parameters:
format- The log entry format. e.g."[{date} {level}] {msg}%n" The string can contain any of the following variables:"{date}" - The date, formatted per"Logging/dateFormat" ."{class}" - The class name."{method}" - The method name."{logger}" - The logger name."{level}" - The log level name."{msg}" - The log message."{threadid}" - The thread ID."{exception}" - The localized exception message.
dateFormat- TheSimpleDateFormatformat to use for dates. e.g."yyyy.MM.dd hh:mm:ss" .useStackTraceHashes- Iftrue , only print unique stack traces once and then refer to them by a simple 8 character hash identifier.
-
-
Method Details
-
format
-
getDateFormat
Returns theDateFormatused for matching dates.- Returns:
- The
DateFormatused for matching dates.
-
getField
Given a matcher that has matched the pattern specified bygetLogEntryPattern(), returns the field value from the match.- Parameters:
fieldName- The field name. Possible values are:"date" "class" "method" "logger" "level" "msg" "threadid" "exception"
m- The matcher.- Returns:
- The field value, or
null if the specified field does not exist.
-
getLogEntryPattern
Returns the regular expression pattern used for matching log entries.- Returns:
- The regular expression pattern used for matching log entries.
-