Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the default logging of Akka ActorSystem

I need an ActorSystem that does not log anything. Trying HTTP things with spray, I'm so stupid that I can't help copying and pasting their example code here. As you would see they're using ActorSystem, whose default config messes up the stdout with a whole bunch of INFO. So how do you make an ActorSystem that fits to my need? If it could be done without any external XML or config files, I would love the way. Thank you! :)

like image 384
Ryoichiro Oka Avatar asked Mar 18 '23 17:03

Ryoichiro Oka


1 Answers

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

What's done here

  • Manually created an instance of Typesafe Config
  • Set log level values to highest level possible.
  • Constructed ActorSystem with explicit configuraion (docs here).

At this point you shouldn't see any messages during system startup and any spray notification

like image 150
alkersan Avatar answered Mar 21 '23 06:03

alkersan