title: Log4j 2 JSON pattern layout + Logging JSON payload
body: <p>I am using ELK stack along with <strong>log4j 2 via sl4j with <code>json</code> pattern layout</strong> to log messages. All my logs are logged as <code>json</code> messages.Also in one of my logs I am trying to log the <code>json</code> response received from the third party service. But this response <code>json</code> body is not appended to the <code>json</code> structure. But it rather appended as a string including the escape characters.</p>
  
  <p><strong>how the ultimate logs being logged out.</strong></p>
  
  <pre><code> {
      "timeMillis": 1471862316416,
      "thread": "FioranoMQ Pubsub Session Thread",
      "level": "INFO",
      "loggerName": "com.mlp.eventing.bridge.fiorano.TopicMessageListener",
      "message": "{\"Msgtype\":\"SentToRabbitMqTest\",\"MessageData\":\"10\",\"opration\":\"devide\"}",
      "endOfBatch": false,
      "loggerFqcn": "org.apache.logging.slf4j.Log4jLogger",
      "threadId": 28,
      "threadPriority": 5
  }
  </code></pre>
  
  <p>In above message segment is appended as escaped strings rather than the entire <code>json</code> structure. My expected out put should be</p>
  
  <pre><code>{
      "timeMillis": 1471862316416,
      "thread": "FioranoMQ Pubsub Session Thread",
      "level": "INFO",
      "loggerName": "com.mlp.eventing.bridge.fiorano.TopicMessageListener",
      "message": {
          "Msgtype": "SentToRabbitMqTest",
          "MessageData": "10",
          "opration": "devide"
      },
      "endOfBatch": false,
      "loggerFqcn": "org.apache.logging.slf4j.Log4jLogger",
      "threadId": 28,
      "threadPriority": 5
  }
  </code></pre>
  
  <p>I am expecting to extract the fields in the  message segment using the grok filters for <code>json</code> in <code>shipper.conf</code></p>
  
  <p>Below are my configurations :-
  log4j2.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="info"&gt; &lt;!-- log4j internals tracing --&gt;
      &lt;properties&gt;
          &lt;property name="pattern"&gt;%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5.5p | %-20.20C:%-5.5L | %msg%n&lt;/property&gt;
          &lt;property name="filePath"&gt;/opt/mlp/logs&lt;/property&gt; 
          &lt;property name="fileName"&gt;logs&lt;/property&gt;
      &lt;/properties&gt;
      &lt;Appenders&gt;
          &lt;RollingFile name="RollingFile" fileName="${filePath}/${fileName}.log"
                       filePattern="${filePath}/${fileName}-%d{yyyy-MM-dd}-%i.log" append="true"&gt;
              &lt;JSONLayout complete="false" compact="true" eventEol="true" /&gt;  
              &lt;PatternLayout&gt;
                  &lt;pattern&gt;${pattern}&lt;/pattern&gt;
              &lt;/PatternLayout&gt;
              &lt;Policies&gt;
                  &lt;SizeBasedTriggeringPolicy size="1000 KB"/&gt; 
              &lt;/Policies&gt;l
          &lt;/RollingFile&gt;
          &lt;Console name="STDOUT" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout&gt;
                  &lt;pattern&gt;${pattern}&lt;/pattern&gt;
              &lt;/PatternLayout&gt;
          &lt;/Console&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Root level="debug"&gt;
              &lt;AppenderRef ref="RollingFile"/&gt;
              &lt;AppenderRef ref="STDOUT"/&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>sample code snippet </p>
  
  <pre><code>import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  class A {
  private static final Logger LOG = LoggerFactory.getLogger(Main.class);
  
  public void testMethod()  {
  
  JSONObject responseJson = callService();// json simple object
  LOG.info(responseJson);
  
  }
  
  }
  </code></pre>
  
  <p>maven dependencies </p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;1.7.21&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j-slf4j-impl&lt;/artifactId&gt;
              &lt;version&gt;2.6.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- end adding sl4j 2 for the message bridge --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
              &lt;version&gt;2.6.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
              &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
              &lt;version&gt;2.6.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!--
          to enable json support for log4j enable following libraries
          --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
              &lt;version&gt;2.7.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
              &lt;version&gt;2.7.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
              &lt;version&gt;2.7.5&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>