From 372e5608035776103c793e7457012cdad78fde24 Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Tue, 19 Sep 2017 22:03:26 +0100 Subject: [PATCH] MINOR: Only include transactional id in LogContext if it's set --- .../org/apache/kafka/clients/producer/KafkaProducer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java b/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java index b630d611dc235..7d51640f5ed1d 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java @@ -316,7 +316,11 @@ private KafkaProducer(ProducerConfig config, Serializer keySerializer, Serial String transactionalId = userProvidedConfigs.containsKey(ProducerConfig.TRANSACTIONAL_ID_CONFIG) ? (String) userProvidedConfigs.get(ProducerConfig.TRANSACTIONAL_ID_CONFIG) : null; - LogContext logContext = new LogContext(String.format("[Producer clientId=%s, transactionalId=%s] ", clientId, transactionalId)); + LogContext logContext; + if (transactionalId == null) + logContext = new LogContext(String.format("[Producer clientId=%s] ", clientId)); + else + logContext = new LogContext(String.format("[Producer clientId=%s, transactionalId=%s] ", clientId, transactionalId)); log = logContext.logger(KafkaProducer.class); log.trace("Starting the Kafka producer");