Configuring Logback via Groovy in an SBT Project

I wanted to use logback for my tests’ logging on an SBT project recently, and it took a little while to work out how best to do it. The good news is that it turns out to be simple enough (once you know what to do).

In your build.sbt add dependencies for Groovy and Logback Classic (I have restricted them just to ‘test’ scope as I only want this to apply to my tests)

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2" % "test"
libraryDependencies += "org.codehaus.groovy" % "groovy-all" % "2.4.1" % "test"

Then put your logback.groovy in the root of your /test/resources folder.

That’s it - logging during test execution should now be under the control of your logback.groovy config.

comments powered by Disqus