简体   繁体   中英

ClassNotFoundException when adding slf4j to Akka

The following is the error trace that I got while adding slf4j to my Akka project.

.....
[DEBUG] [05/07/2019 10:12:00.959] [main] [EventStream] StandardOutLogger started
error while starting up loggers
akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due to [java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger]
.....
Caused by: java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger
.....
Exception in thread "main" akka.ConfigurationException: Could not start logger due to [akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due to [java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger]]
.....

Any idea on how to fix this issue?

This issue can be solved by adding the akka-slf4j dependency to your Akka project.

    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor_2.12</artifactId>
        <version>2.5.22</version>
    </dependency>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-slf4j_2.12</artifactId>
        <version>2.5.22</version>
    </dependency>

NOTE: Make sure your akka-actor and akka-slf4j have the same versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM