Akka Logging outside Actor

后端 未结 6 1556
孤街浪徒
孤街浪徒 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

    I've now settled on simply passing my central logging system around through DI constructor injection (Guice). And in my classes that do logging regularly (where asynchronicity is important), I take the injected ActorSystem and call the

    this.log = akka.event.Logging.getLogger(actorSystem, this);
    

    in the classes constructor.

提交回复
热议问题