Reputation: 1402
Coming from the SLF4j world, I'm used to being able to use this syntax (via the Logstash encoder library) to provide key/value pairs:
MY_SLF4J_LOGGER.info("I'm processing a file", kv("file-id", 1234), kv("line-number", 42));
I know that Log4j2 supports key/value pairs via the MDC and via map-based logging, but is there a way to provide key/value pairs on a single log statement like the above SLF4j example? (Adding something to the MDC for a single log statement seems like overkill for a lot of my use cases.)
Upvotes: 0
Views: 56