Reputation: 3495
I want to print logs on console and also write them in a file. In my scala project using akka loggers here is my build.sbt
libraryDependencies ++= Seq("org.mongodb" %% "casbah" % "2.8.0",
"org.slf4j" % "slf4j-simple" % "1.7.12",
"org.elasticsearch" % "elasticsearch" % "1.5.0",
"org.scalatest" %% "scalatest" % "2.2.1" % "test"
withSources() withJavadoc(),
"org.easymock" % "easymock" % "3.1" withSources() withJavadoc(),
"org.mockito" % "mockito-all" % "1.9.5",
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
"ch.qos.logback" % "logback-classic" % "1.0.9",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.9")
and here is a part of my code
import akka.event.Logging
val log = Logging(context.system, this)
case RegularAdminWriteInMongo =>
log.debug("writing to mongo")
log.info("message received RegularAdminWriteInMongo")
when i run my program in sbt following message printed
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar: file: /home/sara / .ivy2 / cache / org.slf4j / slf4j - simple / jars / slf4j - simple - 1.7.12.jar!/org/slf4j / impl / StaticLoggerBinder.class] SLF4J: Found binding in [jar: file: /home/sara / .ivy2 / cache / ch.qos.logback / logback - classic / jars / logback - classic - 1.0.9.jar!/org/slf4j / impl / StaticLoggerBinder.class] SLF4J: See http: //www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type[org.slf4j.impl.SimpleLoggerFactory] [ArteciateActorSystem - akka.actor. default -dispatcher - 3] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started[ArteciateActorSystem - akka.actor. default -dispatcher - 2] INFO models.AdminUserModels.AdminUserModelsActors.RegularAdminWriteMongoActor - message received RegularAdminWriteInMongo
after that my other println statements are printed ,Please help me how to stop displaying this message ,also please do not mark my question as duplicate as its been asked before i looked into it but it does not solve my problem..please help thanks
Upvotes: 12
Views: 49793
Reputation: 3825
The error message already tells you everything you need to know. The link provided in the message (http://www.slf4j.org/codes.html#multiple_binding) says:
SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.
Your classpath includes two bindings for SLF4J:
/home/sara/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.12.jar
and
/home/sara/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.9.jar
Make sure there is only one binding on your classpath and the warning will not be shown again.
To summarize: Remove slf4j-simple from your dependencies, logback-classic is enough.
Upvotes: 29