Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.10.0
-
None
-
None
Description
I want to add extra parameters to structured Json output, and can do that by using ThreadContext, like shown in code below.
ThreadContext.put("key1", value1); ThreadContext.put("key2", value2); timerLogger.info("Values"); ThreadContext.remove("key1"); ThreadContext.remove("key2");
This is very intrusive in the code, and I tried to use MapMessage instead like this:
this. logger.info(new MapMessage().with("key1", "value1").with("key2", "value2"));
I see that the MapMessage can format messages as key="value", json, java and XML. I use a JsonAppender to ouput a format that is easy indexable by our log-management system. But the MapMessage is not output as json. I get this:
"message" : "key1=\"value1\" key2=\"value2\"",
But I want:
"message" : {"key1" : "value1", "key2" : "value2" }