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
174 stars 81 forks source link

slf4j bridge - init lock #789

Closed justcoon closed 10 months ago

justcoon commented 10 months ago

add init log for slf4j bridge more like in case of zio app, where there is just one initialisation it is not issue

but in case of tests, and multiple parallel initialisations, it is making issues like:

- Slf4jBridge - parallel init
  Exception in thread "zio-fiber-91,78" java.lang.ClassCastException: class org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to class zio.logging.slf4j.bridge.LoggerFactory (org.slf4j.helpers.SubstituteLoggerFactory and zio.logging.slf4j.bridge.LoggerFactory are in unnamed module of loader sbt.internal.LayeredClassLoader @3c6460fa)
  at zio.logging.slf4j.bridge.Slf4jBridge$.$anonfun$layer$3(Slf4jBridge.scala:43)
  at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
  at zio.logging.slf4j.bridge.Slf4jBridge.layer(Slf4jBridge.scala:39)
  at zio.logging.slf4j.bridge.Slf4jBridge.layer(Slf4jBridge.scala:37)
  at zio.logging.slf4j.bridge.Slf4jBridgeSpec.spec(Slf4jBridgeSpec.scala:27)
  at zio.logging.slf4j.bridge.Slf4jBridgeSpec.spec(Slf4jBridgeSpec.scala:24)
  Exception in thread "zio-fiber-90,79" java.lang.ClassCastException: class org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to class zio.logging.slf4j.bridge.LoggerFactory (org.slf4j.helpers.SubstituteLoggerFactory and zio.logging.slf4j.bridge.LoggerFactory are in unnamed module of loader sbt.internal.LayeredClassLoader @3c6460fa)
  at zio.logging.slf4j.bridge.Slf4jBridge$.$anonfun$layer$3(Slf4jBridge.scala:43)
  at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
  at zio.logging.slf4j.bridge.Slf4jBridge.layer(Slf4jBridge.scala:39)
  at zio.logging.slf4j.bridge.Slf4jBridge.layer(Slf4jBridge.scala:37)
  at zio.logging.slf4j.bridge.Slf4jBridgeSpec.spec(Slf4jBridgeSpec.scala:27)
  at zio.logging.slf4j.bridge.Slf4jBridgeSpec.spec(Slf4jBridgeSpec.scala:24)
  Exception in thread "zio-fiber-87,80" java.lang.ClassCastException: class org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to class zio.logging.slf4j.bridge.LoggerFactory (org.slf4j.helpers.SubstituteLoggerFactory and