Skip to content

Commit 3f88693

Browse files
garyrussellartembilan
authored andcommitted
Add group.id to container info logs
Useful if multiple containers for the same topics in the same application.
1 parent 4d4eb80 commit 3f88693

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/AbstractMessageListenerContainer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,18 @@ protected final ConsumerRebalanceListener createSimpleLoggingConsumerRebalanceLi
372372

373373
@Override
374374
public void onPartitionsRevoked(Collection<TopicPartition> partitions) {
375-
AbstractMessageListenerContainer.this.logger.info("partitions revoked: " + partitions);
375+
Log logger2 = AbstractMessageListenerContainer.this.logger;
376+
if (logger2.isInfoEnabled()) {
377+
logger2.info(getGroupId() + ": partitions revoked: " + partitions);
378+
}
376379
}
377380

378381
@Override
379382
public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
380-
AbstractMessageListenerContainer.this.logger.info("partitions assigned: " + partitions);
383+
Log logger2 = AbstractMessageListenerContainer.this.logger;
384+
if (logger2.isInfoEnabled()) {
385+
logger2.info(getGroupId() + ": partitions assigned: " + partitions);
386+
}
381387
}
382388

383389
};

spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,9 @@ public void wrapUp() {
893893
if (this.errorHandler != null) {
894894
this.errorHandler.clearThreadState();
895895
}
896-
this.logger.info("Consumer stopped");
896+
if (this.logger.isInfoEnabled()) {
897+
this.logger.info(getGroupId() + ": Consumer stopped");
898+
}
897899
publishConsumerStoppedEvent();
898900
}
899901

0 commit comments

Comments
 (0)