logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robin Coe <rcoe.java...@gmail.com>
Subject Re: JSONLayout serializes the MDC as a List<Map<String,String>>?
Date Mon, 04 Jan 2016 20:24:58 GMT
I can see that XML entities requires conforming to a schema but isn't the
writer implementation capable of wrapping the map entries when required?
Seems like it's making the JSON representation more complex (and less
performant) at the cost of some wrapper code for the xml writer.

On Mon, Jan 4, 2016 at 3:19 PM, Gary Gregory <garydgregory@gmail.com> wrote:

> Yes, that is because we can define this kind of structure with XML/JSON
> schema with ease.
> Gary
> On Jan 4, 2016 11:55 AM, "Robin Coe" <rcoe.javadev@gmail.com> wrote:
>> I was trying to deserialize a log event written by the JSONLayout
>> appender, which uses Jackson.  I therefore also am using Jackson but with
>> the MrBeanModule, which is a POJO materializer.  After much difficulty with
>> Jackson throwing deserialization exceptions with the "contextMap" field, I
>> learned that the map is actually written out as a List of Maps (i.e.
>> List<Map<String,String>>.  I've included one such event here, with
>> unnecessary fields shortened:
>> {"timeMillis":...,"thread":"...","level":"OFF","loggerName":"...","message":"...","endOfBatch":false,"loggerFqcn":"...","contextMap":[{"key":"LOGROLL","value":"com.xxx.xxx.handler.event.FailoverHandler"},{"key":"ROUTINGKEY","value":"elasticsearch-rollover"}]}
>> I'm curious why the contextMap is represented as the more complex List of
>> single entry Maps, as opposed to a single multi-valued Map?  So, instead of
>> something that looks like:
>> {"contextMap":[{"key":"key1"},{"value":"value1"},{"key":"key2"},{"value":"value2"},...]
>> I would expect the much simpler (and easily parseable):
>>     {"contextMap":{"key1":"value1","key2":"value2",...}.
>> Is this intended?
>> Thanks,
>> Robin.

View raw message