Repository navigation
Replies: 4 comments
|
What do the APIs look like for structured logging? I couldn't find any API doc in the repo with a quick look. |
|
@jkwatson Rainbow Gum only supports key values and no deeply nested JSON objects other than exact specific formats like logstash, ECS and GELF. The SLF4J API which is the predominant API only would allow that through its LoggingEventBuilder addKeyValue methods as it is the only method other than parameters that take an Object (parameters not really being designed for that). The reason we don't allow arbitrary objects in key values is because of threading concerns so all key values are strings. Its important to understand that Rainbow Gum is more of the philosophy/mindset that logging is diagnostic and not a business event sourcing framework where you are doing actual analytics with highly structured events. I know Open Telemetry makes that blurry but basically we don't do that. Furthermore arguably that is something JFR can do as well where you can make custom events if you wanted custom event diagnostics. On the plus side most applications I find even business applications sort of abusing logging for business analytics don't need deeply nested structured json events. |
|
Also of note Scoped Values which Rainbow Gum does have as a way to add MDC like meta data on each API is unlikely to have String->Object mapping either in SLF4J 3.0 based on current works and given that Structured You can see more about that here: https://jstach.io/doc/rainbowgum/current/apidocs/#scoped_key_values BTW I'm unaware of Logback or Log4J2 (even with its own facade) providing an API for doing nesting of objects in an event other than Log4J2 custom Message interface but I have never seen it done. Event Springs structured logging is basically just keys and values largely coming from MDC or the addKeyValues all of which Rainbow Gum does support. Is there specific API/Facade I should look at that does this? |
|
For others as I'm fairly sure @jkwatson is familiar with SLF4J. Rainbow Gum’s primary application-facing API is SLF4J, including its fluent key/value API: logger.atInfo()
.addKeyValue("orderId", orderId)
.addKeyValue("attempt", 3)
.log("Retrying order");Rainbow Gum supports "structured logging" through named fields, but deliberately stores application key/value values as strings. For example, the attempt above becomes "3". It does not preserve arbitrary objects as nested structured values. This keeps value capture and asynchronous delivery predictable without requiring an object-serialization contract. Our encoders provide the output format’s structure; application-supplied fields remain string-valued. |
Uh oh!
There was an error while loading. Please reload this page.
Rainbow Gum is a logging framework that is a replacement for Log4J2 or Logback:
https://github.com/jstachio/rainbowgum
It has support for open telemetry in 0.15.0 (soon to be 1.0.0):
https://jstach.io/doc/rainbowgum/current/apidocs/#otlp
Folks often ask why use Rainbow Gum instead of Log4j2/Logback:
https://github.com/jstachio/rainbowgum/blob/main/why_rainbowgum_is_better.md
I could not find a show and tell option but figured this might help someone given the OLTP logback appender is not that reliable based on my testing.
All reactions