Blog Post

Implementing NLog in Akka.NET

Sunday, February 26, 2017 1:42 PM

Today I needed to implement logger into my Akka.Net demo. This is how to implement it.

You will need to install NLogger package (



This package contains mapping between internal log system and NLog. This will save to write this yourself.

Ok lets carry on. 

We need to setup our system to work with internal logging framework. By default it displays colour coded messages in console. 


We need to implement in our actor 

interface ILoggingAdapter

Now how do I get instance of this?

We will create a new property as follows. The Context is in base Actor class that our actor is inheriting from

private ILoggingAdapter _logger = Context.GetLogger();

Now we need to setup our actor framework to know about the NLog so we can use it.

for that we need to modify app.config or web.config using hocon configuration



    <section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />

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

Finally we need to add NLog config file.

I have used existing nuget package that allows me to do so using package (


Now just edit the nlog configuration as you want.