[improve] PIP-467: Convert pulsar-client module logging from SLF4J to slog#25507
Merged
nodece merged 7 commits intoapache:masterfrom Apr 13, 2026
Merged
[improve] PIP-467: Convert pulsar-client module logging from SLF4J to slog#25507nodece merged 7 commits intoapache:masterfrom
nodece merged 7 commits intoapache:masterfrom
Conversation
RawReaderImpl in pulsar-broker extends ConsumerImpl which now uses slog Logger, so pulsar-broker needs the slog dependency to compile.
Convert the SLF4J-style log.debug() call to slog fluent API since RawReaderImpl inherits the slog Logger from ConsumerImpl.
RawBatchMessageContainerImpl calls add() without setting a producer, causing NPE on producer.getProducerName(). Use lazy lambda to make the attr null-safe.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the pulsar-client (and a small set of related broker-side client impl code) from SLF4J-style logging to slog structured logging to support PIP-467, including adding context-enriched “derived” loggers and standardizing attribute-based log fields.
Changes:
- Replaced SLF4J loggers/usages with
slog+ Lombok@CustomLogacross client main/test code. - Added derived loggers (e.g.,
LOG.with().attr(...).build()) to attach stable context (topic, subscription, channel, IDs). - Updated build configuration to depend on
libs.sloginstead oflibs.slf4j.apiwhere applicable.
Reviewed changes
Copilot reviewed 105 out of 105 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar-client/src/test/java/org/apache/pulsar/client/tutorial/SampleCryptoProducer.java | Convert tutorial logging to slog with attrs + exception handling. |
| pulsar-client/src/test/java/org/apache/pulsar/client/tutorial/SampleCryptoConsumer.java | Convert tutorial logging to slog; use attrs for message content and exceptions. |
| pulsar-client/src/test/java/org/apache/pulsar/client/tutorial/SampleConsumerListener.java | Convert tutorial logging to slog structured fields. |
| pulsar-client/src/test/java/org/apache/pulsar/client/tutorial/SampleAsyncProducerWithSchema.java | Convert async producer tutorial logging to slog (attrs + exception). |
| pulsar-client/src/test/java/org/apache/pulsar/client/tutorial/SampleAsyncProducer.java | Convert async producer tutorial logging to slog (attrs + exception). |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/ProtobufSchemaTest.java | Replace SLF4J with Lombok @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/ProtobufNativeSchemaTest.java | Replace SLF4J with Lombok @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/PrimitiveSchemaTest.java | Replace SLF4J with @CustomLog; convert info logs to attrs. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/KeyValueSchemaTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/KeyValueSchemaInfoTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/JSONSchemaTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericSchemaTest.java | Replace SLF4J with @CustomLog; convert debug/info logs to attrs. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericSchemaImplTest.java | Replace SLF4J with @CustomLog; convert logs to attrs. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReaderTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericAvroReaderTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/AbstractGenericSchemaTest.java | Replace SLF4J with @CustomLog; convert decode log to attrs. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/AvroSchemaTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchemaTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/ConnectionTimeoutTest.java | Convert info log to slog attrs. |
| pulsar-client/src/test/java/org/apache/pulsar/client/impl/AutoClusterFailoverTest.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/test/java/org/apache/pulsar/client/api/ConsumerConfigurationTest.java | Replace explicit SLF4J logger with @CustomLog; convert log format to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/util/ScheduledExecutorProvider.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/util/RetryUtil.java | Replace SLF4J logger with @CustomLog; convert retry warning to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/util/ExecutorProvider.java | Replace SLF4J with @CustomLog; convert uncaught-exception handler and shutdown warnings to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ZeroQueueConsumerImpl.java | Convert listener debug/error/warn logs to structured slog calls. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/UnAckedMessageTracker.java | Replace SLF4J logger with @CustomLog; convert redelivery info log to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/UnAckedMessageRedeliveryTracker.java | Replace SLF4J logger with @CustomLog; convert redelivery info log to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/TransactionMetaStoreHandler.java | Replace SLF4J logger with @CustomLog; convert connection and request lifecycle logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionImpl.java | Replace SLF4J with @CustomLog; convert send/ack failure logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionCoordinatorClientImpl.java | Replace SLF4J logger with @CustomLog; convert start/close logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/transaction/TransactionBuilderImpl.java | Replace SLF4J with @CustomLog; convert build logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryProducerInterceptor.java | Replace SLF4J logger with @CustomLog; convert tracing logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/tracing/OpenTelemetryConsumerInterceptor.java | Replace SLF4J logger with @CustomLog; convert tracing logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/TopicListWatcher.java | Introduce slog Logger with derived context attrs; convert watcher lifecycle logs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/TableViewImpl.java | Introduce slog Logger with topic context; convert message handling and reader logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/ProtobufReader.java | Replace SLF4J with @CustomLog; convert close-error logging to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/MultiVersionAvroReader.java | Replace SLF4J with @CustomLog; convert schema-load logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/JsonReader.java | Replace SLF4J with @CustomLog; convert close-error logging to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/JacksonJsonReader.java | Replace SLF4J with @CustomLog; convert close-error logging to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AvroReader.java | Replace SLF4J with @CustomLog; convert close-error logging to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/reader/AbstractMultiVersionReader.java | Replace SLF4J with @CustomLog; convert schema-version error logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/ProtobufNativeSchemaUtils.java | Replace SLF4J logger with @CustomLog; convert debug logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/KeyValueSchemaImpl.java | Replace SLF4J with @CustomLog; convert schema configuration logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/JSONSchema.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/MultiVersionSchemaInfoProvider.java | Replace SLF4J with @CustomLog; convert cache failure logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/MultiVersionGenericProtobufNativeReader.java | Replace SLF4J with @CustomLog; convert schema-version logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/MultiVersionGenericJsonReader.java | Replace SLF4J with @CustomLog; convert schema-version logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/MultiVersionGenericAvroReader.java | Replace SLF4J with @CustomLog; convert schema-version logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeSchema.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReader.java | Replace SLF4J with @CustomLog; convert init error log to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonSchema.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonRecord.java | Replace SLF4J with @CustomLog; convert parse-failure log to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericJsonReader.java | Replace SLF4J with @CustomLog; convert close-error log to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericAvroSchema.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericAvroRecord.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericAvroReader.java | Replace SLF4J with @CustomLog; convert close-error log to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AvroSchema.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchema.java | Replace SLF4J with @CustomLog; convert schema configuration logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractStructSchema.java | Replace SLF4J logger with @CustomLog; rely on structured logger. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/SameAuthParamsLookupAutoClusterFailover.java | Replace SLF4J with @CustomLog; convert cluster probe/failover logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ReaderImpl.java | Switch to slog Logger with derived context; convert ack failure logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarServiceNameResolver.java | Replace SLF4J with @CustomLog; convert resolver logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientSharedResourcesImpl.java | Replace SLF4J with @CustomLog; convert close warning to .exception(t). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java | Replace SLF4J logger with @CustomLog; convert lifecycle/error logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarChannelInitializer.java | Replace SLF4J with @CustomLog; convert TLS error logs to .exception(e). |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerStatsRecorderImpl.java | Replace SLF4J logger with @CustomLog; convert periodic stats logs to attributes. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerInterceptors.java | Replace SLF4J logger with @CustomLog; convert interceptor error logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java | Replace SLF4J with @CustomLog; convert flush debug logging to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PatternMultiTopicsConsumerImpl.java | Switch to slog Logger with derived context; convert pattern consumer logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PatternConsumerUpdateQueue.java | Switch to slog Logger with derived context; convert task lifecycle logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PartitionedTopicProducerStatsRecorderImpl.java | Replace SLF4J logger with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/PartitionedProducerImpl.java | Switch to slog Logger with derived context; convert creation/close/auto-update logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/NegativeAcksTracker.java | Replace SLF4J logger with @CustomLog; convert redelivery log to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsReaderImpl.java | Switch to slog Logger with derived context; convert ack failure logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicConsumerStatsRecorderImpl.java | Replace SLF4J logger with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/MemoryLimitController.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpLookupService.java | Replace SLF4J logger with @CustomLog; convert warnings/errors to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/HttpClient.java | Replace SLF4J with @CustomLog; convert request failure logs to attrs/exceptionMessage. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/GeoReplicationProducerImpl.java | Switch to slog Logger with derived context; convert replication ack logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/DefaultCryptoKeyReader.java | Replace SLF4J logger with @CustomLog; convert key load logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ControlledClusterFailover.java | Replace SLF4J with @CustomLog; convert control-plane polling/switch logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerStatsRecorderImpl.java | Replace SLF4J logger with @CustomLog; convert periodic stats logs to attributes. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerInterceptors.java | Replace SLF4J logger with @CustomLog; convert interceptor logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBuilderImpl.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBase.java | Switch to slog Logger with derived context; convert consumer lifecycle logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java | Replace SLF4J logger with @CustomLog; convert connection lifecycle logs to attrs/exceptionMessage. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionHandler.java | Switch to slog Logger with derived context; convert reconnection logs to attrs/exceptionMessage. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/BinaryProtoLookupService.java | Replace SLF4J logger with @CustomLog; convert lookup/schema/topic list logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageKeyBasedContainer.java | Replace SLF4J logger with @CustomLog; convert batch debug logs to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java | Replace SLF4J logger with @CustomLog; convert batch build/discard logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/AutoClusterFailover.java | Replace SLF4J with @CustomLog; convert failover logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/FlowBase.java | Replace SLF4J with @CustomLog; convert OAuth2 metadata/config logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/ClientCredentialsFlow.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java | Replace SLF4J with @CustomLog; convert token refresh logs to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationKeyStoreTls.java | Replace SLF4J with @CustomLog; convert parse fallback log to attrs. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataTls.java | Replace SLF4J logger with @CustomLog; convert refresh errors to attrs/exception. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationDataKeyStoreTls.java | Replace SLF4J with @CustomLog. |
| pulsar-client/src/main/java/org/apache/pulsar/client/impl/AbstractBatchMessageContainer.java | Replace SLF4J with @CustomLog. |
| pulsar-client/build.gradle.kts | Swap client dependency from slf4j.api to slog. |
| pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawReaderImpl.java | Convert a debug log to structured slog usage. |
| pulsar-broker/build.gradle.kts | Add libs.slog dependency to support updated logging usage. |
…umerStatsRecorderImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…umerInterceptors.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace printStackTrace() with structured logging in ProtobufNativeSchemaUtils - Fix attr key "0" to "durationSeconds" in TableViewImpl - Fix connection pool debug message grammar - Fix "consumername" to "consumerName" in ConsumerInterceptors - Use .exception(e) and descriptive messages in stats recorders
nodece
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pulsar-clientfrom SLF4J to slog structured logging.exception(e)for Throwable objects and lazy attrs for mutable valuesTest plan
compileJavaandcompileTestJavapasscheckstyleMainandcheckstyleTestpassMotivation
PIP-467
Note
Please label this PR with
ready-to-test