Support logback 1.6.x in the logback toolkit layouts (#837)

* Support logback 1.6.x in the logback toolkit layouts

Logback 1.6.0 removed PatternLayout.defaultConverterMap, which
TraceIdPatternLogbackLayout and TraceIdMDCPatternLogbackLayout wrote their
conversion words to in a static initializer, so both failed with
NoSuchFieldError: defaultConverterMap (apache/skywalking#14120).

The layouts now register their conversion words in the logging context's
conversion rule registry (CoreConstants.PATTERN_RULE_REGISTRY) when they
start, updating it in place as logback does for <conversionRule>. Logback
1.2.x to 1.6.x all read class names from that registry, so the same toolkit
artifact keeps working on older logback. Logback 1.5.13 is not supported
because of an upstream regression fixed in 1.5.14 (qos-ch/logback#885).

The toolkit now compiles against logback 1.6.5, so an API removal fails the
build. LogbackVersionCompatibilityTest renders both layouts against logback
1.2.13, 1.3.16, 1.4.14, 1.5.12, 1.5.14, 1.5.38 and 1.6.5, each loaded in an
isolated class loader.

Add apm-toolkit-logback-scenario, the first plugin test of the logback
toolkit and its agent activation. It runs logback 1.2.x to 1.5.x with the
released toolkit and checks the trace ID and SkyWalking context rendered by
both layouts, including behind an AsyncAppender, through the gRPC log
reporter.

* Replace the conversion rule registry instead of modifying it

Register the SkyWalking conversion words by replacing the context's
conversion rule registry with an updated copy, under the context monitor
held only for the copy. Layouts starting concurrently, from any class
loader, keep each other's words, and logback reads a registry that is
never modified afterwards, so no lock is held while logback creates and
starts the converters. Nothing is copied once the words are registered.

On logback before 1.5.14, which also writes <conversionRule>s to this
registry, a rule logback registers at the same time as a layout starts in
another thread may be lost; this is documented.
19 files changed
tree: b77266ba9fb202f19fb60285e957cd026dbbab7d
  1. .claude/
  2. .github/
  3. .mvn/
  4. apm-application-toolkit/
  5. apm-checkstyle/
  6. apm-commons/
  7. apm-protocol/
  8. apm-sniffer/
  9. changes/
  10. dist-material/
  11. docs/
  12. test/
  13. tools/
  14. .asf.yaml
  15. .dlc.json
  16. .dockerignore
  17. .gitignore
  18. .gitmodules
  19. .licenserc.yaml
  20. CHANGES.md
  21. CLAUDE.md
  22. codeStyle.xml
  23. CONTRIBUTING.md
  24. Dockerfile
  25. HEADER
  26. LICENSE
  27. lombok.config
  28. Makefile
  29. mvnw
  30. mvnw.cmd
  31. NOTICE
  32. pom.xml
  33. README.md
README.md

Apache SkyWalking Java Agent

GitHub stars Twitter Follow

Maven Central CI

SkyWalking-Java: The Java Agent for Apache SkyWalking, which provides the native tracing/metrics/logging abilities for Java projects.

SkyWalking: an APM(application performance monitor) system, especially designed for microservices, cloud native and container-based (Docker and Kubernetes) architectures.

Documentation

Downloads

Please head to the releases page to download a release of Apache SkyWalking.

Code of conduct

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please follow the REPORTING GUIDELINES to report unacceptable behavior.

Live Demo

Find the demo and screenshots on our website.

Contact Us

  • Mail list: dev@skywalking.apache.org. Mail to dev-subscribe@skywalking.apache.org, follow the reply to subscribe the mail list.
  • Send Request to join SkyWalking slack mail to the mail list(dev@skywalking.apache.org), we will invite you in.
  • For Chinese speaker, send [CN] Request to join SkyWalking slack mail to the mail list(dev@skywalking.apache.org), we will invite you in.
  • Twitter, ASFSkyWalking
  • bilibili B站 视频

License

Apache 2.0 License.