merlimat opened a new pull request, #4770:
URL: https://github.com/apache/bookkeeper/pull/4770

   ## Summary
   
   - Slog attributes are forwarded to log4j2 as ContextData (the same channel 
SLF4J's MDC uses). Add `%X` to every PatternLayout in the user-facing log4j2 
configs (`conf/`, `bookkeeper-server/src/main/resources/`, `stream/conf/`, 
`bookkeeper-benchmark/conf/`) so that the structured attrs attached via 
`.attr(...)` show up in log output by default.
   - Drop the now-redundant `*MDC` variant appenders in `conf/log4j2.xml` and 
the `directentrylogger` override that targeted them — every appender renders 
the context map now.
   - Add `conf/log4j2.otel-json.xml` plus `conf/otel-log-template.json` as an 
example layout that emits each event as a single JSON object aligned with the 
[OpenTelemetry log data 
model](https://opentelemetry.io/docs/specs/otel/logs/data-model/): `timestamp`, 
`severity_text`, `severity_number`, `body`, `instrumentation_scope.name`, 
`resource.{service.name,host.name}`, `attributes` (the full ContextData map), 
`trace_id`/`span_id`/`trace_flags` from MDC, plus 
`exception.{type,message,stack_trace}`.
   - The OTel example uses `JsonTemplateLayout`, which requires 
`org.apache.logging.log4j:log4j-layout-template-json` on the classpath at 
runtime (not bundled by default — the example header notes this).
   
   ## Test plan
   
   - [x] `xmllint --noout` validates every modified XML config.
   - [x] `python3 -m json.tool` validates `conf/otel-log-template.json`.
   - [ ] Confirm via existing test runs that the log4j2 configuration still 
loads cleanly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to