Package org.rapidcontext.util
Class LogFormatter
java.lang.Object
java.util.logging.Formatter
org.rapidcontext.util.LogFormatter
A java.util.logging formatter with more output options. Adds to the default
simple formatter by indenting multiple line entries, shortening stack
traces, and removing the "org.rapidcontext" prefix for class names.
Configured by the following properties:
org.rapidcontext.logging.format
-- same format parameters and options as java.util.logging.SimpleFormatter.formatorg.rapidcontext.logging.format.indent
-- indentation prefix for subsequent log lines (default is 4 spaces)
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFormats the specified log record for output.protected String
Returns the source class and method for a log record.protected String
getStackTrace
(LogRecord entry) Returns the stack trace from a log record.protected String
indentFollowing
(String log) Returns an indented log output string.Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
-
Field Details
-
DEFAULT_FORMAT
Default logging format.- See Also:
-
FORMAT
The log output format. Configured via the logging property "org.rapidcontext.logging.format". Uses same available formats and parameters as the java.util.logging.SimpleFormatter.format -
INDENT
The indentation prefix for subsequent log lines. Configured via the logging property "org.rapidcontext.logging.format.indent". Default is 4 spaces.
-
-
Constructor Details
-
LogFormatter
public LogFormatter()Creates a new log formatter instance.
-
-
Method Details
-
format
Formats the specified log record for output. -
getSource
Returns the source class and method for a log record.- Parameters:
entry
- the log record to use- Returns:
- the source class and method, or the logger name if not set
-
getStackTrace
Returns the stack trace from a log record.- Parameters:
entry
- the log record to use- Returns:
- the formatted stack trace, or an empty string if not set
-
indentFollowing
Returns an indented log output string.- Parameters:
log
- the log output string- Returns:
- the indented version of the log output
-