Reputation:
I'm pretty new to Akka and I'm having trouble getting the application.conf
file to load. I've defined a relatively simple conf file, consisting of:
akka {
logLevel = "NONE"
stdout-logLevel = "NONE"
}
From what I understand, this should be picked up automatically (having put it in the src/main/resources
directory). However, when I load the default logger and output "INFO" (doing greet) messages, I am still seeing them in the console (see following code).
import akka.actor.{ActorRef, Actor, Props}
import akka.event.Logging
object HelloWorldActor {
case object Tick
}
class HelloWorldActor extends Actor {
val logger = Logging(context.system, this)
var greeter : Option[ActorRef] = None
override def preStart() = {
greeter = Some(context.actorOf(Props[Greeter], "greeter"))
}
def doGreet(): Unit = {
logger.info("doing greet")
greeter match {
case Some(g) => g ! Greeter.Greet
}
}
def receive: Actor.Receive = {
case HelloWorldActor.Tick => this.doGreet()
}
}
The only thing I can think of is that I have defined a kernel to run it in stand-alone mode and I'm not sure if there is something extra that I should be doing there to load the configuration.
I've put my project up on GitHub for better inspection of what I am doing:https://github.com/JohnMurray/hello-akka
Any help is greatly appreciated since I'm currently an Akka newbie. Also, I should mention that I have read through the config documentation online, but it didn't help me in this particular case.
thanks!
Upvotes: 6
Views: 7779
Reputation: 1342
Try putting your file into src/main/resources/ - application.conf is not a scala file, so it doesn't belong in src/main/scala/resources which is the folder for the package root.resources scala sources.
OK. I see what is the problem now. I don't think there's a loglevel setting NONE.
According to the doc there are four settings:
# Options: ERROR, WARNING, INFO, DEBUG
loglevel = "DEBUG"
Try setting it to WARNING.
Also, you have typo in loglevel - please note it's not a camelCase name, but all-lower loglevel.
Side note - add akka microkernel plugin to your SBT build and add runner that can be launched either with run or re-start action.
Upvotes: 13