structured arguments + nested keys ("a.b.c") produce 'flat' JSON output
nouknouk opened this issue · comments
Nouknouk commented
Hi,
I'm using structured arguments:
logger.info("foo txt {}", value("bar.foo", 42));
This is a very, very convenient way for the developer to structure value in his logs with an efficient syntax.
This produces the following json output:
{
"bar.foo": 42
}
I wonder if there is any way to make encoder produce instead:
{
"bar": {
"foo": 42
}
}
Without the (less convenient) need of writing intermediate objects (JsonNode, ...) to pass to the logger.
Regards.
Phil Clay commented
That is not possible currently. I'm also hesitant to introduce this functionality in logstash-logback-encoder, since it will require some complex parsing and grouping logic.
I'd recommend using Maps as intermediaries.
logger.info("foo txt {}", value("bar", Map.of("foo", 42)));