Akka Logging outside Actor

后端 未结 6 1433
孤街浪徒
孤街浪徒 2021-01-30 09:02

I have an Akka Actor that makes a call to MyObject.foo(). MyObject is not an Actor. How do I setup Logging in it? With an Actor it\'s simple, because

6条回答
  •  终归单人心
    2021-01-30 09:35

    Using Akka 2.2.1, I was able to put this into my App to get logging outside of an actor:

    import akka.event.Logging
    val system = ActorSystem("HelloSystem", ConfigFactory.load.getConfig("akka"))
    val log = Logging.getLogger(system, this)
    log.info("Hi!")
    

    This seems like a simpler solution for unifying an application's logging.

提交回复
热议问题