2017-06-17 146 views
0

我有一个工作akka-http应用程序。现在我尝试通过slf4j和logback添加日志记录以及我的应用程序崩溃。akka-http当添加slf4j/logback时崩溃

build.sbt

libraryDependencies ++= Seq(
    "com.typesafe.akka" %% "akka-http" % "10.0.7", 
    "ch.qos.logback" % "logback-classic" % "1.2.3", 
    "com.typesafe.akka" %% "akka-slf4j" % "2.5.2" 
) 

application.conf

akka { 
    loggers = ["akka.event.slf4j.Slf4jLogger"] 
    loglevel = "DEBUG" 
    logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" 
} 

logback.xml

<?xml version="1.0" encoding="UTF-8"?> 
<configuration debug="true"> 

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
     <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> 
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> 
     </encoder> 
    </appender> 

    <root level="DEBUG"> 
     <appender-ref ref="STDOUT"/> 
    </root> 
</configuration> 

错误:

Detected java.lang.NoSuchMethodError error, which MAY be caused by incompatible Akka versions on the classpath. Please note that a given Akka version MUST be the same across all modules of Akka that you are using, e.g. if you use akka-actor [2.5.2 (resolved from current classpath)] all other core Akka modules MUST be of the same version. External projects like Alpakka, Persistence plugins or Akka HTTP etc. have their own version numbers - please make sure you're using a compatible set of libraries.

Uncaught error from thread [my-system-akka.actor.default-dispatcher-6] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[my-system] java.lang.NoSuchMethodError: akka.actor.ActorCell.addFunctionRef(Lscala/Function2;)Lakka/actor/FunctionRef;

据消息,这是一个兼容性问题。如何找出哪些版本的akka-httpakka-slf4j兼容(除了试用)?

在一个侧面说明,因为它是一个类似的问题:我想添加akka-stream。然而,使用akka-httpakka-stream的最新版本给我在sbt驱逐警告。与上面相同的问题:如何找出要使用的版本?

回答

2

不幸的是akka-httpakka的其余部分分开版本化,最新版本不一定使用最新版本akka。在akka-http版本10.0.7的情况下,兼容的akka版本是2.4.18。你可以看到它here。这意味着您需要在akka-slf4j依赖关系中下降到该版本以运行应用程序,而不会出现问题。

相关问题