Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Akka.NET to log all messages received by actors?

I am trying to make Akka.NET log all messages received by actors but can't get this to work. Here's my configuration (I am using projects from Akka.NET bootcamp):

      akka {                
        stdout-loglevel = DEBUG
        loglevel = DEBUG
        log-config-on-start = on

        actor {
          debug {
            receive = on # log any received message
            autoreceive= on # log automatically received messages, e.g. PoisonPill
            lifecycle = on # log actor lifecycle changes
            event-stream = on # log subscription changes for Akka.NET event stream
            unhandled = on # log unhandled messages sent to actors
          }
        }
      }

I can see that the configuration works for other activities (I see debug messages about actor system initialization and shutdown) but nothing from actual messages sent to actors. I tried both C# and F# examples.

like image 504
Vagif Abilov Avatar asked Jan 12 '16 08:01

Vagif Abilov


People also ask

What is Akka logging?

Logging in Akka is not tied to a specific logging backend. By default log messages are printed to STDOUT, but you can plug-in a SLF4J logger or your own logger. Logging is performed asynchronously to ensure that logging has minimal performance impact.

What is actor model in Akka?

Akka Actors The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems.

What is an actor C#?

The actor is C# class, which inherits from one of the classes provided by the framework: The actor in this example is a receive actor, which means you'll have to define what types of messages it will be handling. As you can see, the actor will receive three types of messages: BookTheRoom.


1 Answers

Found what I was missing. It's not enough to configure debug logging, an actor must implement a marker interface (with no methods) ILogReceive:

class ConsoleWriterActor : UntypedActor, ILogReceive
like image 132
Vagif Abilov Avatar answered Oct 21 '22 03:10

Vagif Abilov