Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.18.0
-
None
-
None
Description
Extracted from https://issues.apache.org/jira/browse/LOG4J2-3537?focusedCommentId=17570358&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17570358 comment.
After updating from 2.17.2 to 2.18.0 this exception started coming up:
WARN The style attribute bright white is incorrect. java.lang.IllegalArgumentException: No enum constant org.apache.logging.log4j.core.pattern.AnsiEscape.BRIGHT WHITE
at java.base/java.lang.Enum.valueOf(Enum.java:240)
at org.apache.logging.log4j.util.EnglishEnums.valueOf(EnglishEnums.java:67)
at org.apache.logging.log4j.util.EnglishEnums.valueOf(EnglishEnums.java:50)
at org.apache.logging.log4j.core.pattern.AnsiEscape.createSequence(AnsiEscape.java:486)
at org.apache.logging.log4j.core.pattern.StyleConverter.newInstance(StyleConverter.java:96)
for config:
<?xml version="1.0" encoding="UTF-8"?> <Configuration xmlns="http://logging.apache.org/log4j/2.0/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" strict="true" status="warn" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/apache/logging-log4j2/master/log4j-core/src/main/resources/Log4j-config.xsd" > <Properties> <Property name="pattern_level_colors"> FATAL=bright magenta, ERROR=bright red, WARN=bright yellow, INFO=dim white, DEBUG=bright black, TRACE=cyan </Property> <Property name="pattern_styled">%highlight{%date{ISO8601} %-5level [%thread] %logger(%file:%line)}{${ pattern_level_colors}} %style{%message}{bright white}%n%style{%throwable}{BG_red,white} </Property> </Properties> <Appenders> <Appender type="Console" name="color-console"> <Layout type="PatternLayout" pattern="${pattern_styled}" /> </Appender> </Appenders>
doing this fixed the issue:
-%style{%message}{bright white} +%style{%message}{bright_white}
pkarwasz said
The problem you are having is not with the highlight pattern, but the style pattern:
- the highlight pattern separates the keywords with white space: e.g. "INFO=bright white",
- the style pattern separates the keywords with commas: e.g. "bright, white".
I agree that this is inconsistent, but it is easily fixable: instead of just using commas as separators in the style pattern, we can use commas or white space. This way we take care of backward compatibility and bring some consistency to the two patterns.
Attachments
Issue Links
- is caused by
-
LOG4J2-3537 Ansi escape code for highlight is generated wrong
- Resolved