logging-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-2062) Add possibility of sending the key of a message to Kafka using KafkaAppender
Date Thu, 05 Oct 2017 17:00:14 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-2062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16193191#comment-16193191
] 

ASF GitHub Bot commented on LOG4J2-2062:
----------------------------------------

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.


> Add possibility of sending the key of a message to Kafka using KafkaAppender
> ----------------------------------------------------------------------------
>
>                 Key: LOG4J2-2062
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2062
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Appenders
>    Affects Versions: 2.9.0, 2.9.1
>            Reporter: Jorge Sanchez
>            Assignee: Mikael Ståldal
>            Priority: Minor
>
> When using the KafkaAppender the KafkaManager only sends the value of a message to a
Kafka topic. 
> It could be useful to be able to assign a value to the key of that message via configuration
instead of having it null.
> Check https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/kafka/KafkaManager.java#L99
> Updated with link to the PR: https://github.com/apache/logging-log4j2/pull/112



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message