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:
Slf4jEventHandler
: ~/.ivy2/cache/com.typesafe.akka/akka-slf4j_2.10/jars/akka-slf4j_2.10-2.3.0-RC4.jar
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With