2017-06-17 3 views
0

私は動作中のakka-httpアプリケーションを持っています。今、私はslf4jとログバックを介してログを追加しようとし、私のアプリケーションがクラッシュします。slf4j/logbackを追加するとakka-httpがクラッシュする

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-httpは、akkaの残りの部分とは別にバージョンが付けられており、最新のバージョンは必ずしも最新のバージョンakkaを使用するとは限りません。 akka-httpバージョン10.0.7の場合、対応するakkaバージョンは2.4.18です。あなたはそれを見ることができますhere。つまり、問題なくアプリケーションを実行するには、そのバージョンのバージョンをakka-slf4jにする必要があります。

関連する問題