@Plugin(name="highlightError",
category="Converter")
public class HighlightErrorConverter
extends org.apache.logging.log4j.core.pattern.LogEventPatternConverter
HighlightConverter
that uses
TerminalConsoleAppender
to detect if Ansi escape codes can be used
to highlight errors and warnings in the console.
If configured, it will mark all logged errors with a red color and all
warnings with a yellow color. It can be only used together with
TerminalConsoleAppender
.
TerminalConsoleAppender.ANSI_OVERRIDE_PROPERTY
may be used
to force the use of ANSI colors even in unsupported environments.
Example usage: %highlightError{%level: %message}
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ANSI_ERROR |
private static java.lang.String |
ANSI_RESET |
private static java.lang.String |
ANSI_WARN |
private java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> |
formatters |
Modifier | Constructor and Description |
---|---|
protected |
HighlightErrorConverter(java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> formatters)
Construct the converter.
|
Modifier and Type | Method and Description |
---|---|
void |
format(org.apache.logging.log4j.core.LogEvent event,
java.lang.StringBuilder toAppendTo) |
private void |
format(java.lang.String style,
org.apache.logging.log4j.core.LogEvent event,
java.lang.StringBuilder toAppendTo) |
boolean |
handlesThrowable() |
static HighlightErrorConverter |
newInstance(org.apache.logging.log4j.core.config.Configuration config,
java.lang.String[] options)
Gets a new instance of the
HighlightErrorConverter with the
specified options. |
format, isVariable
private static final java.lang.String ANSI_RESET
private static final java.lang.String ANSI_ERROR
private static final java.lang.String ANSI_WARN
private final java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> formatters
protected HighlightErrorConverter(java.util.List<org.apache.logging.log4j.core.pattern.PatternFormatter> formatters)
formatters
- The pattern formatters to generate the text to highlightpublic void format(org.apache.logging.log4j.core.LogEvent event, java.lang.StringBuilder toAppendTo)
format
in class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
private void format(java.lang.String style, org.apache.logging.log4j.core.LogEvent event, java.lang.StringBuilder toAppendTo)
public boolean handlesThrowable()
handlesThrowable
in class org.apache.logging.log4j.core.pattern.LogEventPatternConverter
@Nullable public static HighlightErrorConverter newInstance(org.apache.logging.log4j.core.config.Configuration config, java.lang.String[] options)
HighlightErrorConverter
with the
specified options.config
- The current configurationoptions
- The pattern options