You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Manuel Meiners (JIRA)" <ji...@apache.org> on 2016/04/19 07:51:25 UTC

[jira] [Created] (LOG4J2-1371) JSONLayout and MultiformatMessage

Manuel Meiners created LOG4J2-1371:
--------------------------------------

             Summary: JSONLayout and MultiformatMessage
                 Key: LOG4J2-1371
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1371
             Project: Log4j 2
          Issue Type: Bug
    Affects Versions: 2.5
            Reporter: Manuel Meiners


I configured an appender with JSONLayout

{code:xml}
<Console name="Console" target="SYSTEM_OUT" >
    <JSONLayout compact="false" />
</Console>
{code}

After logging a MapMessage in following way:

{code:java}
final MapMessage mapMessage = new MapMessage();
mapMessage.put("firstname", "John");
mapMessage.put("lastname", "Doe");

LogManager.getLogger().error(mapMessage);
{code}

I get following log output:

{code}
{
  "timeMillis" : 1461044392388,
  "thread" : "main",
  "level" : "ERROR",
  "loggerName" : "com.prognost.spectest.testcases.dccard.rest.RestSpecExecutorTest",
  "message" : "firstname=\"John\" lastname=\"Doe\"",
  "endOfBatch" : false,
  "loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger"
}
{code}

As you can see the MapMessage was not serialized to JSON. It's the same for other MultiformatMessage implementations. It seems to me that the MultiformatMessage::getFormattedMessage method isn't called with "json".



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org