BP-69: Convert bookkeeper-server to slog (phase 3)#4756
Merged
merlimat merged 5 commits intoapache:masterfrom Apr 28, 2026
Merged
BP-69: Convert bookkeeper-server to slog (phase 3)#4756merlimat merged 5 commits intoapache:masterfrom
merlimat merged 5 commits intoapache:masterfrom
Conversation
Minimal scaffolding commit for the BP-69 slog migration series: - Add `io.github.merlimat.slog:slog:0.9.7` to the root pom.xml dependencyManagement and to the global compile classpath alongside the existing SLF4J API (which stays as the rendering backend). - Add lombok.config at the repo root so `@CustomLog` generates a slog `Logger` instead of an SLF4J one. - Register the slog jar in LICENSE-all.bin.txt, LICENSE-server.bin.txt and LICENSE-bkctl.bin.txt so the CI check-binary-license script finds it accounted for in the bundled-jars list. No actual Java file is converted in this commit. Individual module migrations stack on top of this one.
36a7ddc to
3d7dedd
Compare
This was referenced Apr 24, 2026
Also includes a few follow-ups now that 0.9.8 is in use: - Wrap method-call attr values in Supplier for lazy evaluation on debug/ trace log calls that were originally guarded by isXxxEnabled. The fluent slog form would otherwise eagerly evaluate the attr arguments even when the level is disabled. - Simplify the response promise in PacketProcessorBase: always attach a ChannelFutureListener (the listener body itself uses log.debug() and is cheap when debug is off) rather than the side-effecting lambda. Mock newPromise() with RETURNS_SELF in ReadEntryProcessorTest so the chained .addListener() returns the same mock. - Update MdcContextTest assertions for the new bare slog messages (ledgerId / entryId / firstEntry / lastEntry are now structured attrs rather than baked into the message string). With the slog 0.9.8 fix, MDC propagates through the log4j2 backend and the test verifies that.
…ormat
The slog conversion of SimpleTestCommand turned the original
LOG.info("{} entries written to ledger {}", numEntries, ledgerId)
into a structured form that lost the substring TestCLI and
TestBookieShellCluster's test001_SimpleTest assert on ("100 entries
written to ledger"). The default log4j2 PatternLayout in the
bookkeeper image prints %m only, so the structured attrs are not
visible to the integration tests that inspect command stdout.
Use logf() to bake the values into the message so it again matches
the integration-test expectations. The progress-line log on line 118
similarly drops a non-descriptive single-letter "i" attr in favor
of the formatted '<count> entries written'.
Same regression as SimpleTestCommand: the slog conversion lost the verbatim message text 'LastLogMark : Journal Id - <id>(<hex>.txn), Pos - <offset>' that the integration test BkCtlTest.showLastMark asserts on. Default log4j2 PatternLayout prints %m only, so structured attrs are not visible to integration tests that inspect command stdout. Use logf() to bake the values into the message.
zymap
approved these changes
Apr 28, 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
Part of BP-69 (SLF4J to slog migration). Converts the
bookkeeper-servermodule to use slog for structured logging.This PR is stacked on #4754 (common, phase 1) and #4755 (stats, phase 2), but has its own minimal base commit so it can merge independently:
BP-69 base: add slog dependency and LICENSE entries— minimal scaffolding: adds slog to rootpom.xml, updatesLICENSE-*.bin.txtfiles, and addslombok.configfor the@CustomLogannotation.BP-69: Convert bookkeeper-server from SLF4J to slog— the actual module conversion (252 files).Conversion patterns applied
LoggerFactory.getLogger(Foo.class)/@Slf4j→ Lombok@CustomLoggenerating a slogLogger.log.info("text {} {}", a, b)→log.info().attr("nameA", a).attr("nameB", b).log("text")— values become typed structured attributes.log.error("msg", exception)→log.error().exception(exception).log("msg").if (log.isDebugEnabled()) { ... }→ lambda formlog.debug(e -> e.attr(...).log(...))where the cost of evaluation matters.ledgerId,entryId,thread,directory,fileInfo, etc.No changes to log output format — slog with the SLF4J backend produces equivalent output.
Test plan
mvn -pl bookkeeper-server compilepassesmvn -pl bookkeeper-server checkstyle:checkpassesmvn -pl bookkeeper-server testpasses in CI