2017-03-04 8 views
3

私はAkkaとAkka-httpを使って簡単なサーバーを開発しています。SLF4Jからのクラス「org.slf4j.impl.StaticLoggerBinder」のエラーを読み込めません

私はいつも、私はIntelliJのにアプリケーションを実行すると標準出力にエラーメッセージが表示され、次の取得:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 

私はbuild.gradleに次の依存関係があります。

compile 'org.scala-lang:scala-library:2.12.1' 
compile 'com.typesafe.akka:akka-actor_2.12:2.4.17' 
compile 'com.typesafe.akka:akka-stream_2.12:2.4.17' 
compile 'com.typesafe.akka:akka-http_2.12:10.0.4' 
compile 'com.typesafe.akka:akka-http-spray-json_2.12:10.0.4' 
compile 'com.typesafe.akka:akka-slf4j_2.12:2.4.17' 

をそして私はとapplication.confてきました以下のようになります。

最後に、このようなログを使用しています:

object HttpServer extends App with JsonSupport { 
    override def main(args: Array[String]): Unit = { 

    val config = ConfigFactory.load() 

    implicit val system = ActorSystem(config.getString("application.actor-system")) 
    implicit val materializer = ActorMaterializer() 

    // needed for the future flatMap/onComplete in the end 
    implicit val executionContext = system.dispatcher 

    val logger = Logging(system, getClass) 

なぜ私はいつもそのエラー文を知ることができますか?

答えて

6

SLF4Jバックエンドを提供する必要があります - Akka docsログバックをお勧めします。これは、以下のように依存関係に追加することで実現します。依存関係をコンパイル時には必要ないので、Runtimeとしてフラグを立てることもできます。

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3" % Runtime 

これは、アッカの特定の要件ではありませんのでご注意ください:SLF4Jが唯一のファサードであり、常にログのバックエンドが必要です。

ログバックを選択した場合は、ログ設定をlogback.xmlに設定することをお勧めします。詳細はthis answerを参照してください。

Akkaのログインについて知りたいことは、docsです。

+1

はい、動作します。私はそれを忘れていたと信じられない!ご協力いただきありがとうございます! –

+1

これは私のために働いた - 警告を取り除いたが、代わりに私はいくつかの画面をデバッグと情報ログの価値がある。上記の答えのドキュメントリンクは、[この回答](https://stackoverflow.com/a/32003907)(基本的に 'logback.xml'を追加し、必要に応じて設定)と同様に役立ちます。 – fazy

関連する問題