We are changing our logs from Text to JSON. I used below code to implement JSON logs :
LayoutWrappingEncoder layoutEncoder = new LayoutWrappingEncoder();
ch.qos.logback.contrib.json.classic.JsonLayout layout= new ch.qos.logback.contrib.json.classic.JsonLayout();
ch.qos.logback.contrib.jackson.JacksonJsonFormatter jsonFormatter=new ch.qos.logback.contrib.jackson.JacksonJsonFormatter();
jsonFormatter.setPrettyPrint(true);
layout.setJsonFormatter(jsonFormatter);
layout.setTimestampFormat("yyyy-MM-dd' 'HH:mm:ss.SSS");
layoutEncoder.setLayout(layout);
But I see that JSON logs are not printed entirely.
{
"timestamp" : "2019-08-22 10:12:15.790",
"level" : "ERROR",
"thread" : "qtp1346354118-22",
"logger" :"com.SomeClass",
"message" : "Exception from : com.class.method() \n",
"context" : "default",
"exception" : "java.lang.NullPointerException: null\r\n"
}
Now, the exception are not printed with complete stack trace, like how they use to get logs in text logs. Also I could see new line escape sequence getting printed which also does not happen in text logs.
I tried exploring some properties in JSONLayout but none of them solved my problem.
So what else can I try here.