• DOCUMENTATION 
  • CODE 
  • PROJECT CHAT 
  • MAILING LIST 
  • COMMERCIAL SUPPORT 
  • RESOURCES 
  • Home
  • Docs
  • Serilog (Edit on Github)

Akka.NET Docs

Using Serilog

Setup

Install the package Akka.Logger.Serilog to utilize Serilog

PM> Install-Package Akka.Logger.Serilog

This will also install the required Serilog packages.

Next, you'll need to configure the global Log.Logger and also specify to use the logger in the config when creating the system, for example like this:

var logger = new LoggerConfiguration()
    .WriteTo.ColoredConsole()
    .MinimumLevel.Information()
    .CreateLogger();
Serilog.Log.Logger = logger;
var system = ActorSystem.Create("my-test-system", "akka { loglevel=INFO,  loggers=[\"Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog\"]}");

Logging

To log inside an actor, using the normal string.Format() syntax, get the logger and log:

var log = Context.GetLogger();
...
log.Info("The value is {0}", counter);

To log using Serilog syntax you need to use the SerilogLogMessageFormatter:

var log = Context.GetLogger(new SerilogLogMessageFormatter());
...
log.Info("The value is {Counter}", counter);
 

About Akka.NET

Akka.NET is a port of the popular
Java/Scala framework Akka to .NET.

This is a community driven port and
is not affiliated with Typesafe who
makes the original Java/Scala version.

hi@rogeronazure.om

Recent Tweets

Keep Updated

Subscribe to our Newsletter