log4j2-logstash-layout icon indicating copy to clipboard operation
log4j2-logstash-layout copied to clipboard

Fallback for json:map: fields for libraries

Open akleiman opened this issue 5 years ago • 1 comments

Currently we're looking into adopting MapMessages for most of our logging needs, mapping the message fieldin the layout as, say json:map:message. This works fine for our code, but when dealing with library code that logs SimpleMessages we end up with empty message fields. Is there a workaround for this, some way to fallback a field from json:map: mapping to message if the mapping is empty?

akleiman avatar Aug 07 '20 22:08 akleiman

If I understand you correctly, what you are looking for is an if-else construct, which exists neither in LogstashLayout, nor its successor JsonTemplateLayout, yet. JsonTemplateLayout allows one to fallback to PatternLayout, though neither PatternLayout allows such a check, AFAIK. Hence, AFAIC, this feature needs to be implemented from scratch.

vy avatar Aug 11 '20 10:08 vy