Logback is the successor of Log4j and is one of the better logging frameworks around. In this post, we would quickly see how to set it up on a Scala project and how to start using it.
The relevant dependency to be included in your build.sbt is
libraryDependencies += “ch.qos.logback” % “logback-classic” % “1.0.1”
Once, you have this set, next you have to get a logback.xml file in your classpath. If you are using a sbt generated project, the best place to put it would be /src/main/resources and for your tests, you could put a logback-test.xml in /src/test/resources
A sample, logback.xml file would look like this
Once these are done, next let us just test it out. Following is a small Scala program to check
and the output
Entire code for this sample is present on the Knoldus github site