Skip to content

BP-69: Adopt slog for structured logging#4751

Open
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:bp-69-slog-structured-logging
Open

BP-69: Adopt slog for structured logging#4751
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:bp-69-slog-structured-logging

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Motivation

This PR adds BP-69: Adopt slog for structured logging for discussion.

BookKeeper currently uses SLF4J with unstructured {}-style format strings. This makes logs hard to query in modern log backends (Loki, Elastic, Splunk, etc.), forces every call site to restate identity context (ledgerId, bookieId, entryId, …) inline, and requires isDebugEnabled() guards on hot paths to avoid String.format/toString cost.

Apache Pulsar PIP-467 reached the same conclusion, chose the slog library, and its migration is complete. Because Pulsar is BookKeeper's largest user, a shared logging substrate lets cross-project debugging chains stay structured end-to-end.

The BP also covers retiring the existing bookkeeper-slogger module (only 5 main-source files use it, all in bookkeeper-server), and adds an API for callers to attach their own context attributes to a ledger Handle via withLoggerContext(Map<String, Object>) on CreateBuilder/OpenBuilder/DeleteBuilder — so e.g. Pulsar's managedLedger=<topic> attribute can appear automatically on BookKeeper client log lines without BookKeeper knowing about Pulsar concepts.

Tracking issue: #4750

Summary

  • New BP document: site3/website/src/pages/bps/BP-69-slog-structured-logging.md
  • Listed as Under Discussion in site3/website/src/pages/community/bookkeeper-proposals.md
  • Next proposal number bumped to 70
  • This PR is not associated with any release or milestone (per BP process)

Test plan

  • N/A — proposal document only

Proposal to migrate BookKeeper from SLF4J to the slog structured-logging
library (mirroring Pulsar PIP-467), and to add a public client API method
withLoggerContext(Map<String, Object>) on CreateBuilder/OpenBuilder/
DeleteBuilder so callers can attach their own logging context attributes to
a ledger Handle. Retires the existing bookkeeper-slogger module (5 internal
call sites, no external adoption).

Tracking issue: apache#4750
@merlimat merlimat added the BP label Apr 17, 2026
@merlimat merlimat requested review from hangc0276, lhotari and zymap April 17, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant