Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-15783

Unable to set batchSize in log4j2 Kafka appender

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 3.6.0
    • None
    • logging
    • None

    Description

      When I try to configure the batchSize of the Kafka log4j2 appender the application logs the following error:

      ERROR StatusConsoleListener Kafka contains an invalid element or attribute "batchSize"
      

      This is an example of configuration that fails:

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration status="WARN">
      	<Appenders>
      		<Console name="LogToConsole" target="SYSTEM_OUT">
      			<PatternLayout
      				pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
      		</Console>
      		<Kafka name="Kafka" topic="log-collector" syncSend="false"
      			batchSize="8192">
      			<PatternLayout
      				pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
      			<Property name="bootstrap.servers">localhost:9092</Property>
      		</Kafka>
      	</Appenders>
      	<Loggers>
      		<Root level="info">
      			<AppenderRef ref="LogToConsole" />
      			<AppenderRef ref="Kafka" />
      		</Root>
      		<Logger name="org.apache.kafka" level="WARN" /><!-- avoid recursive
      		logging -->
      	</Loggers>
      </Configuration>
      

      Please note that other parameters like syncSend work fine.

      Could be possible that log4j2 expects this field:

      https://github.com/apache/kafka/blob/3.6.0/log4j-appender/src/main/java/org/apache/kafka/log4jappender/KafkaLog4jAppender.java#L83C11-L83C11

      as a String for working fine?

      Attachments

        Activity

          People

            Unassigned Unassigned
            diepet Diego Pettisani
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: