SAP / cf-java-logging-support

The Java Logging Support for Cloud Foundry supports the creation of structured log messages and the collection of request metrics
Apache License 2.0
76 stars 46 forks source link

Refactor json generation log4j2 #142

Closed KarstenSchnitter closed 2 years ago

KarstenSchnitter commented 2 years ago

Use Jackson directly to serialise the Log4j log events. Removes the old pattern layout approach. The new approach provides several callback and customisation features. They enable users to extend the library within their own applications. Furthermore, support for custom fields has been extended to support non-string values for top level fields. Also, CloudFoundry's VCAP environment variables are no longer added by default. The user has to opt in those fields

The refactoring gives a factor 3 improvement on the JMH benchmarks for simple logs and an unchanged performance for request logs:

Benchmark Mode Cnt Score Error Units
EncodingBenchmarks.minimalRequestRecord thrpt 5 107274,684 ± 39379,575 ops/s
EncodingBenchmarks.simpleLog thrpt 5 504838,974 ± 21313,854 ops/s
EncodingBenchmarks.singleCommonFieldFromMdc thrpt 5 439796,897 ± 12174,050 ops/s
EncodingBenchmarks.singleCustomFieldFromArgument thrpt 5 535903,222 ± 109794,213 ops/s