Github user mikaelstaldal commented on a diff in the pull request:
https://github.com/apache/logging-log4j2/pull/112#discussion_r142995363
--- Diff:
log4j-core/src/test/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaAppenderTest.java
---
@@ -135,6 +135,22 @@ public void testAsyncAppend() throws Exception {
assertEquals(LOG_MESSAGE, new String(item.value(),
StandardCharsets.UTF_8));
}
+ @Test
+ public void testAppendWithKey() throws Exception {
+ final Appender appender =
ctx.getRequiredAppender("KafkaAppenderWithKey");
+ final LogEvent logEvent = createLogEvent();
+ appender.append(logEvent);
+ final List<ProducerRecord<byte[], byte[]>> history =
kafka.history();
+ assertEquals(1, history.size());
+ final ProducerRecord<byte[], byte[]> item = history.get(0);
+ assertNotNull(item);
+ assertEquals(TOPIC_NAME, item.topic());
+ String msgKey = item.key().toString();
+ byte[] keyValue = "key".getBytes();
--- End diff --
Specify same charset here also.
---