Show / Hide Table of Contents

    Logging

    For more info see real Akka's documentation: http://doc.akka.io/docs/akka/2.0/scala/logging.html

    How to Log

    To log in an actor, create a logger and assign it to a private field:

    private readonly ILoggingAdapter _log = Logging.GetLogger(Context);
    

    Use the Debug, Info, Warning and Error methods to log.

    _log.Debug("Some message");
    

    Standard Loggers

    Akka.NET comes with two built in loggers.

    • StandardOutLogger
    • BusLogging

    Contrib Loggers

    These loggers are also available as separate nuget packages

    • Akka.Logger.slf4net which logs using slf4net
    • Akka.Logger.Serilog which logs using serilog. See Detailed instructions on using Serilog.
    • Akka.Logger.NLog which logs using NLog

    Note that you need to modify the config as explained below.

    NLog Configuration

    Example NLog configuration inside your app.config or web.config:

    akka {
        loggers = ["Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog"]
    }
    

    The above NLog components can be found on Nuget (https://www.nuget.org/packages/Akka.Logger.NLog/)

    Configuring Custom Loggers

    To configure a custom logger inside your Akka.Config, you need to use a fully qualified .NET class name like this:

    akka {
        loggers = ["NameSpace.ClassName, AssemblyName"]
    }
    

    Logging Unhandled messages

    It is possible to configure akka so that Unhandled messages are logged as Debug log events for debug purposes. This can be achieved using the following configuration setting:

    akka {
        actor.debug.unhandled = on
    }
    

    Example configuration

    akka {  
        stdout-loglevel = DEBUG
        loglevel = DEBUG
        log-config-on-start = on        
        actor {                
            debug {  
                  receive = on 
                  autoreceive = on
                  lifecycle = on
                  event-stream = on
                  unhandled = on
            }
        }  
    
    • Improve this Doc
    Back to top Copyright © 2013-2017 Akka.NET project
    Generated by DocFX