"value-1"); MDC.put("key.bar", "value-2"); // Slf4j for Log4j2 Logger log = LoggerFactory.getLogger(PaymentGatewayApplication.class); log.atInfo() .setMessage("Some message.") .addKeyValue("key.foo", "value-1") .addKeyValue("key.bar", "value-2") .log(); // Log4j2 Logger log = LogManager.getLogger(PaymentGatewayApplication.class); log.info(new StringMapMessage() .with("key", Map.of( "foo", "value-1", "bar", "value-2" )) );