禁用Akka ActorSystem的默认日志记录

Ryo*_*Oka 4 logging scala akka

我需要一个ActorSystem不记录任何内容的东西.用喷雾尝试HTTP的东西,我是如此愚蠢,以至于我无法在这里复制和粘贴他们的示例代码.正如你会看到他们正在使用的ActorSystem,其默认配置会使用一大堆INFO来混淆stdout.那你怎么做一个ActorSystem符合我需要的呢?如果可以在没有任何外部XML或配置文件的情况下完成,我会喜欢这种方式.谢谢!:)

Alk*_*san 7

import spray.http._
import spray.client.pipelining._
import akka.actor.ActorSystem
import com.typesafe.config._

val config = ConfigFactory.load()
     .withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("OFF"))
     .withValue("akka.stdout-loglevel", ConfigValueFactory.fromAnyRef("OFF"))
implicit val system = ActorSystem("AlwaysNameYourSystem", config)
import system.dispatcher // execution context for futures
// ... here goes the rest of example code
Run Code Online (Sandbox Code Playgroud)

这里做了什么

此时,您不应在系统启动和任何喷涂通知期间看到任何消息