Schubert Fernandes created LOG4J2-3080:
------------------------------------------
Summary: Messages logged inconsistently when using
JsonTemplateLayout.
Key: LOG4J2-3080
URL: https://issues.apache.org/jira/browse/LOG4J2-3080
Project: Log4j 2
Issue Type: Bug
Components: JsonTemplateLayout
Affects Versions: 2.14.1
Reporter: Schubert Fernandes
Attachments: log4j.json.event.layout.zip
When using the JsonTemplateLayout and configuring the message with a
fallbackKey...
{code:json}
"message": {
"$resolver": "message",
"fallbackKey": "asString"
}
{code}
the fallbackKey is not consistently used.
When logging via _org.apache.log4j.Category.info(Object)_ the message string is
logged directly without using the property defined in _fallbackKey_, e.g.
{panel}
{"timestamp":"2021-04-21T14:25:27.625+01:00","loggerName":"explore.log4j.json.template.layout.Main","level":"INFO","{color:red}message":"Message
logged using org.apache.log4j.Category.info(Object)"}{color}
{panel}
but when logging using _org.apache.logging.log4j.Logger.info(String)_ the
message is correctly logged in the _asString_ property as required, i.e.
{panel}
{"timestamp":"2021-04-21T14:25:27.628+01:00","loggerName":"explore.log4j.json.template.layout.Main","level":"INFO","{color:green}message":{*"asString"*:"Message
logged using org.apache.logging.log4j.Logger.info(String)"}}{color}
{panel}
Sample Maven project attached to reproduce.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)