zio / zio-logging

Powerful logging for ZIO 2.0 applications, with compatibility with many logging backends out-of-the-box.
https://zio.dev/zio-logging/
Apache License 2.0
172 stars 80 forks source link

Spans are not propagated to the log4j backend #860

Open lukasz-golebiewski opened 1 month ago

lukasz-golebiewski commented 1 month ago

A reproducer is available here: https://github.com/lukasz-golebiewski/zio-logging-example

lukasz-golebiewski commented 1 month ago

Looks like the solution was to concat LogFormat.spans with the default SLF4J log format.

SLF4J.slf4j(LogFormat.spans + SLF4J.logFormatDefault)

Is there a reason why spans are not being logged in the default format?

justcoon commented 1 month ago

Hi @lukasz-golebiewski I think reason for that is that LogFormat of core zio loggers https://github.com/zio/zio-logging/blob/master/core/shared/src/main/scala/zio/logging/LogFormat.scala#L917-L922 also do not contains spans, so they were not added also to slf4j default format

lukasz-golebiewski commented 1 month ago

This is interesting, because an app extending ZIOAppDefault without overridden bootstrap, so using the default zio logger, does log spans out of the box