I am trying to supress logging in my Play framework test cases. One way of achiving this is to have slf4j-nop jar in the classpath instead of other implementations like logback-classic. I was able to do this in sbt as shown below here.
libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.7.6" % "test"
(dependencyClasspath in Test) <<= (dependencyClasspath in Test) map {
_.filterNot(_.data.name.contains("logback-classic"))
}
But I still get the below error when I run my tests
[info] Exception encountered when attempting to run a suite with class name: JobControllerSpec *** ABORTED ***
[info] java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext
[info] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:80)
[info] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:62)
[info] at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$applicationModule$1.apply(GuiceApplicationBuilder.scala:102)
[info] at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$applicationModule$1.apply(GuiceApplicationBuilder.scala:102)
[info] at scala.Option.foreach(Option.scala:257)
[info] at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:101)
[info] at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
[info] at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
[info] at org.scalatestplus.play.OneAppPerSuite$class.app(OneAppPerSuite.scala:126)
[info] at JobControllerSpec.app$lzycompute(JobControllerSpec.scala:12)
[info] ...
[info] Cause: java.lang.ClassNotFoundException: ch.qos.logback.classic.LoggerContext
[info] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[info] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[info] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
[info] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[info] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:80)
[info] at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:62)
[info] at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$applicationModule$1.apply(GuiceApplicationBuilder.scala:102)
[info] at play.api.inject.guice.GuiceApplicationBuilder$$anonfun$applicationModule$1.apply(GuiceApplicationBuilder.scala:102)
[info] at scala.Option.foreach(Option.scala:257)
[info] at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:101)
why there is a hard dependency on logback-classic in LogbackLoggerConfigurator.scala?
This is the state of my dependencies
[project] $ show libraryDependencies
[info] List(org.scala-lang:scala-library:2.11.8, com.typesafe.play:twirl-api:1.1.1, com.typesafe.play:play-server:2.5.4, com.typesafe.play:play-test:2.5.4:test, com.typesafe.play:play-omnidoc:2.5.4:docs, com.typesafe.play:play-netty-server:2.5.4, com.typesafe.play:play-logback:2.5.4, com.typesafe.play:play-cache:2.5.4, com.typesafe.play:play-ws:2.5.4, com.typesafe.play:play-slick:2.0.0, com.typesafe.play:play-slick-evolutions:2.0.0, com.h2database:h2:1.4.187, mysql:mysql-connector-java:5.1.6, net.codingwell:scala-guice:4.1.0, org.scalatestplus.play:scalatestplus-play:1.5.0:test, org.slf4j:slf4j-nop:1.7.6:test)