-
-
Save RichardBradley/f7b1b7c3358779e3559d to your computer and use it in GitHub Desktop.
Akka drops error logs on ActorSystem guardian death
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.idea | |
myApp.log | |
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package akka | |
import akka.actor._ | |
import com.typesafe.config.{ConfigValueFactory, ConfigFactory, Config} | |
import scala.collection.JavaConversions._ | |
object Application { | |
def main(args: Array[String]): Unit = { | |
val system = ActorSystem("test", config) | |
println("Wait a bit for everything to settle down") | |
Thread.sleep(500) | |
println("stuff the logger's mailbox") | |
(1 to 10000).foreach { i => | |
system.log.debug("mailbox stuffing " + i) | |
} | |
println("simulate a failed assertion somewhere in the ActorSystem") | |
system.actorOf(Props(new FailingAssertionActor())) ! "message" | |
println("Wait a bit for everything to settle down, and things to flush") | |
Thread.sleep(500) | |
assert(system.isTerminated) | |
} | |
class FailingAssertionActor | |
extends Actor | |
{ | |
override def receive: Receive = { | |
case x => | |
assert(false, "it is important that this gets logged") | |
} | |
} | |
val config = { | |
System.setProperty("logback.configurationFile", "logback.xml") | |
ConfigFactory.load() | |
.withValue("akka.loggers", ConfigValueFactory.fromIterable(List("akka.event.slf4j.Slf4jLogger"))) | |
.withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("DEBUG")) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.4" | |
libraryDependencies ++= Seq( | |
"com.typesafe.akka" %% "akka-http-experimental" % "1.0-M3", | |
"com.typesafe.akka" %% "akka-http-testkit-experimental" % "1.0-M3" % "test", | |
"com.typesafe.akka" %% "akka-slf4j" % "2.3.7", | |
"ch.qos.logback" % "logback-classic" % "1.1.2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
<file>myApp.log</file> | |
<encoder> | |
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> | |
</encoder> | |
</appender> | |
<root level="all"> | |
<appender-ref ref="FILE" /> | |
</root> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment