I\'m trying to use Typesafe\'s Scala Logging but couldn\'t get it to print any debug message. I expect Scala Logging to print debug message to the default screen but it does
For those who're still struggling for how to make your scala-logging work in your sbt project. They just need to follow these steps:
Add these two dependencies in your build.sbt
:
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2"
Create a file logback.xml in your /src/main/resources/ and paste below mentioned content in that file.
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
/Users/yourusername/test.log
false
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
Extend your Scala class or object with trait LazyLogging
:
import com.typesafe.scalalogging.slf4j.LazyLogging
class MyClass extends LazyLogging {
logger.debug("This is very convenient ;-)")
}
It's done.
P.S: Only a side note that logger is already a member of trait LazyLogging so you don't need to create it (as shown in above example)