Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka (2.3.0) fails to load Slf4jEventHandler class with java.lang.ClassNotFoundException

I migrated from Akka 2.2.3 to 2.3.0-RC4 and got this error message on application startup:

error while starting up loggers
akka.ConfigurationException: Logger specified in config can't be loaded 
[akka.event.slf4j.Slf4jEventHandler] due to
[java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jEventHandler]

I have these SBT dependencies:

val akkaVersion = "2.3.0-RC4"
"com.typesafe.akka" % "akka-actor_2.10" % akkaVersion
"com.typesafe.akka" % "akka-remote_2.10" % akkaVersion
"com.typesafe.akka" % "akka-kernel_2.10" % akkaVersion
"com.typesafe.akka" % "akka-slf4j_2.10" % akkaVersion
"com.typesafe.akka" % "akka-testkit_2.10" % akkaVersion % "test"

Logging worked fine when I was using Akka version 2.2.3 just before I upgraded (no other changes were done in the project).

Here is how I use logger in my application.conf:

akka.loggers = ["akka.event.slf4j.Slf4jEventHandler"]

I've checked the jar files downloaded by SBT and Slf4jEventHandler is present only in older version:

  • Contains NO Slf4jEventHandler: ~/.ivy2/cache/com.typesafe.akka/akka-slf4j_2.10/jars/akka-slf4j_2.10-2.3.0-RC4.jar
  • Contains Slf4jEventHandler: ~/.ivy2/cache/com.typesafe.akka/akka-slf4j_2.10/jars/akka-slf4j_2.10-2.2.3.jar

I wonder if I should use some other logger class, am I missing dependency, or maybe it's not packaged by mistake. I could not find anything in the docs regarding this change.

like image 494
yǝsʞǝla Avatar asked Feb 21 '14 19:02

yǝsʞǝla


1 Answers

I almost opened a ticket because I could not find anything in documentation here or here. But then I found this ticket according to which Slf4jEventHandler is removed because it was deprecated. I followed up this search and found scaladoc which has this deprecation message: "(Since version 2.2) use akka.event.slf4j.Slf4jLogger)".

I updated this line in application.conf:

akka.loggers = ["akka.event.slf4j.Slf4jEventHandler"]

to this:

akka.loggers = ["akka.event.slf4j.Slf4jLogger"]

and it all worked.

I hope you find this solution useful.

like image 98
yǝsʞǝla Avatar answered Oct 15 '22 12:10

yǝsʞǝla