Today I was adding logging to one of my projects. I decided to use scala-logger. I added scala-logger dependency to the build.sbt, excuted my test class and got the following error in the Eclipse console output:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I initially thought it had to do with logback.xml missing from my project, so I added it to the resource directory. Executed my test class again and got the same result. After some Googling it turns out you have to add logback-classic to the sbt dependencies.
These are the required dependencies:
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2"
Just to be complete here is the logback.xml I am using:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${LOG_HOME}/${LOG_FILE_NAME}</file>
<encoder>
<pattern>%date %-5level [%thread] - [%logger] - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
Happy coding!