Search code examples
scalaloggingslickslick-3.0

Silence slick logging


When I run our test suite slick decides to log at debug level, which makes it hard to see our test output and causes the suite to take longer. I can't figure out how to silence it. I've tried using slf4j-nop as suggested in slick's manual, but it seems our project uses several other loggers and slick is making use of one of those. Here's the relevant part of our project definition:

  libraryDependencies ++= Seq(
    "org.apache.spark" %% "spark-mllib" % SparkVersion,
    "org.postgresql" % "postgresql" % "9.3-1101-jdbc41",
    "com.typesafe.slick" %% "slick" % "3.1.1",
    "com.typesafe.slick" %% "slick-hikaricp" % "3.1.1",
    "com.typesafe.slick" %% "slick-codegen" % "3.1.1"
  ),
  dependencyOverrides ++= Set(
    "org.slf4j" % "slf4j-api" % Slf4jVersion,
    "org.slf4j" % "jcl-over-slf4j" % Slf4jVersion,
    "org.slf4j" % "jul-to-slf4j" % Slf4jVersion
  ),
  dependencyOverrides in test := Set(
    "org.slf4j" % "slf4j-nop" % "1.6.4"), //no-op logger for slick

Some of the things I've tried already, none of which work:

  • add logback.xml to the test resources as suggested in Turn Slick logging off.
  • add logging.properties and commons-logging.properties to test resources with .level=WARN
  • add logger.scala.slick=WARN in my application.conf

Solution

  • Slick was using Log4j to do its logging. Strangely enough, just adding an empty src/test/resources/log4j.properties file to the project was good enough to silence it during test runs.