Is there a way to use Kamon logging only in running the code, not in tests?
I'm using kamon-log-reporter
and kamon-scala
on Scala 2.12. My code-under-test uses the Kamon API so I want to have kamon-core
both in Runtime and Test. However, I'm not interested in console logging in tests, and sbt-aspectj-runner
plugin doesn't seem to launch AspectJ for sbt test
(a separate issue).
My setup:
/project/plugins.sbt
resolvers += Resolver.bintrayIvyRepo("kamon-io", "sbt-plugins")
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.0.1")
build.sbt
val kamonVer= "0.6.5"
val kamon = "io.kamon" %% "kamon-core" % kamonVer
val kamonLogging = "io.kamon" %% "kamon-log-reporter" % kamonVer
val kamonAspectJ = "io.kamon" %% "kamon-scala" % kamonVer
libraryDependencies ++= Seq(
kamon, akkaHttp, typesafeConfig, akkaHttpTestkit, scalaTest)
libraryDependencies ++= Seq(kamonLogging, kamonAspectJ)
I've tried this, but it makes logging disappear also in sbt run
:
libraryDependencies in Runtime ++= Seq(kamonLogging, kamonAspectJ)
I would recommend trying
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.2")
In https://github.com/Workday/prometheus-akka/blob/master/build.sbt, I use this to enable aspectjweaver in tests.