![]() |
VOOZH | about |
dotnet add package Akka.Logger.Serilog --version 1.5.69
NuGet\Install-Package Akka.Logger.Serilog -Version 1.5.69
<PackageReference Include="Akka.Logger.Serilog" Version="1.5.69" />
<PackageVersion Include="Akka.Logger.Serilog" Version="1.5.69" />Directory.Packages.props
<PackageReference Include="Akka.Logger.Serilog" />Project file
paket add Akka.Logger.Serilog --version 1.5.69
#r "nuget: Akka.Logger.Serilog, 1.5.69"
#:package Akka.Logger.Serilog@1.5.69
#addin nuget:?package=Akka.Logger.Serilog&version=1.5.69Install as a Cake Addin
#tool nuget:?package=Akka.Logger.Serilog&version=1.5.69Install as a Cake Tool
This is the Serilog integration plugin for Akka.NET. It routes Akka.NET's internal log events through the Serilog pipeline, giving you structured logging with full access to Serilog's enrichment, filtering, and sink ecosystem.
Targets Serilog 2.12.0.
When you configure Akka.NET to use the Serilog logger, all log events from Akka.NET (actor lifecycle messages, dead letters, your own ILoggingAdapter calls, etc.) flow through a SerilogLogger actor that writes them to Serilog's global Log.Logger.
This means your entire Serilog configuration — enrichers, sinks, filters, output templates, minimum levels — applies to Akka.NET log events just like any other log event in your application. Akka.Logger.Serilog doesn't replace or interfere with your Serilog pipeline; it plugs into it.
The following Akka-specific properties are automatically added to every log event:
| Property | Description |
|---|---|
SourceContext |
The full type name of the logging class |
ActorPath |
The path of the actor that produced the log message |
LogSource |
The Akka.NET log source string |
Thread |
The managed thread ID (zero-padded) |
Timestamp |
When the log event was created |
These properties are available in output templates (e.g., {ActorPath}) and in structured log sinks (e.g., Seq, Elasticsearch).
using Akka.Hosting;
using Akka.Logger.Serilog;
var builder = WebApplication.CreateBuilder(args);
// Configure Serilog as usual
builder.Host.UseSerilog((context, config) =>
{
config
.ReadFrom.Configuration(context.Configuration)
.Enrich.FromLogContext()
.WriteTo.Console();
});
// Register Akka.NET with Serilog logging
builder.Services.AddAkka("MySystem", configurationBuilder =>
{
configurationBuilder.ConfigureLoggers(loggerConfigBuilder =>
{
loggerConfigBuilder.AddSerilogLogging();
});
});
AddSerilogLogging() automatically configures both SerilogLogger and SerilogLogMessageFormatter, enabling semantic logging out of the box.
akka {
loggers = ["Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog"]
loglevel = DEBUG
# Required for semantic/structured logging (named template properties)
logger-formatter = "Akka.Logger.Serilog.SerilogLogMessageFormatter, Akka.Logger.Serilog"
}
Make sure you configure the global Serilog.Log.Logger before creating your ActorSystem:
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate:
"{Timestamp:HH:mm:ss} [{Level:u3}] {ActorPath} - {Message:lj}{NewLine}{Exception}")
.CreateLogger();
var system = ActorSystem.Create("MySystem", hoconConfig);
When SerilogLogMessageFormatter is configured (automatic with AddSerilogLogging(), manual with HOCON), named template properties in your log messages are preserved as structured Serilog properties:
var log = Context.GetLogger();
// Named properties - UserId and Action become structured Serilog properties
log.Info("User {UserId} performed {Action}", userId, "login");
// Serilog destructuring operator - User is destructured into its component properties
log.Info("Processing {@User}", userObject);
// Format specifiers work too
log.Info("Total: {Amount:C2}", 1234.56);
These properties appear in your Serilog sinks exactly as they would if you logged directly with Serilog's ILogger.
As of Akka.NET 1.5.60, you can use the built-in WithContext() method on any ILoggingAdapter to add persistent properties to all log messages produced by that adapter. These properties automatically flow through to Serilog as structured properties.
public class OrderProcessorActor : ReceiveActor
{
private readonly ILoggingAdapter _log;
public OrderProcessorActor(string tenantId, string region)
{
// Context properties persist for all messages logged with this adapter
_log = Context.GetLogger()
.WithContext("TenantId", tenantId)
.WithContext("Region", region);
Receive<ProcessOrder>(order =>
{
// This log event will include TenantId, Region, AND OrderId
_log.Info("Processing order {OrderId} for {Amount:C2}", order.Id, order.Amount);
});
}
}
WithContext() is part of core Akka.NET and works with all logging backends (Serilog, NLog, Microsoft.Extensions.Logging), not just Serilog.
Your existing Serilog configuration works exactly as before. Akka.Logger.Serilog writes into the Serilog pipeline — it doesn't replace or modify it.
All of your global enrichers apply to Akka.NET log events:
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext() // ambient async-local context
.Enrich.WithMachineName() // machine name on every event
.Enrich.WithProcessId() // PID on every event
.Enrich.WithThreadId() // thread ID on every event
.Enrich.WithProperty("Application", "OrderService") // static property
.WriteTo.Console()
.CreateLogger();
These enrichers fire on every log event that passes through the Serilog pipeline, including all events from Akka.NET.
JSON-based Serilog configuration is fully supported. All enrichers, sinks, properties, and level overrides configured in your appsettings.json work with Akka.NET log events:
{
"Serilog": {
"Using": ["Serilog.Sinks.Console", "Serilog.Enrichers.Environment"],
"MinimumLevel": {
"Default": "Information",
"Override": {
"System": "Error",
"Microsoft": "Error"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {Level:u3} {ActorPath} - {Message:lj} {Exception}{NewLine}"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"],
"Properties": {
"Application": "MyService"
}
}
}
Note that {ActorPath} and other Akka metadata properties can be used directly in output templates.
Serilog's LogContext.PushProperty() uses async-local (thread-local on .NET Framework) ambient context. Because Akka.NET processes messages on its own dispatcher threads, LogContext properties pushed by the caller won't automatically flow into an actor's log messages — this is inherent to the Akka threading model.
For enriching log messages inside actors, use WithContext() — it travels with the Akka LogEvent across thread boundaries:
// This works - WithContext travels through the Akka pipeline
var log = Context.GetLogger().WithContext("CorrelationId", correlationId);
log.Info("Processing request"); // CorrelationId is present
// This does NOT work inside actors - LogContext is thread-local
using (LogContext.PushProperty("CorrelationId", correlationId))
{
actorRef.Tell(message); // actor processes on a different thread
}
LogContext.PushProperty() is still useful for non-actor code (ASP.NET middleware, background services, etc.) where you control the async context.
Akka.Logger.Serilog supports Akka.NET's built-in log filtering to reduce log noise before messages reach Serilog. This is especially useful on high-volume systems.
Use Akka's LogFilter when:
LogSource (actor paths, class names) — this Akka-specific metadata isn't available in Serilog's filter pipelinevar filters = new LogFilterBuilder()
.ExcludeSourceStartingWith("Akka.Remote.EndpointWriter")
.ExcludeSourceContaining("Heartbeat")
.Build();
var bootstrap = BootstrapSetup.Create()
.WithSetup(filters);
Use Serilog's native filtering when:
TenantId, CorrelationId from WithContext())LogContext.PushProperty()Log.Logger = new LoggerConfiguration()
.Filter.ByExcluding(evt =>
evt.Properties.TryGetValue("TenantId", out var val) &&
val.ToString() == "\"internal\"")
.WriteTo.Console()
.CreateLogger();
Important limitation: Context properties added via WithContext() or LogContext.PushProperty() are applied after Akka's LogFilter runs, so they cannot be filtered using Akka's LogFilter. Use Serilog's native .Filter.ByExcluding() for enricher-based filtering.
Note:
SerilogLoggingAdapter, theForContext()extension method, andContext.GetLogger<SerilogLoggingAdapter>()are deprecated as of Akka.Logger.Serilog 1.5.60. Use the standardILoggingAdapterwithWithContext()instead.
These deprecated APIs still work and will continue to work — they produce compiler warnings but will not be removed until a future major version. Your existing code will compile and run correctly.
If you are migrating from ForContext():
// Old (deprecated - still works, produces compiler warning)
var log = Context.GetLogger<SerilogLoggingAdapter>()
.ForContext("TenantId", "TENANT-001");
// New (recommended)
var log = Context.GetLogger()
.WithContext("TenantId", "TENANT-001");
Why the change? WithContext() is built into core Akka.NET and works identically across all logging backends. This means you can write logging code once and switch between Serilog, NLog, or Microsoft.Extensions.Logging without changing your actor code.
To run the build script associated with this solution, execute the following:
Windows
c:\> build.cmd all
Linux / OS X
c:\> build.sh all
If you need any information on the supported commands, please execute the build.[cmd|sh] help command.
This build script is powered by FAKE; please see their API documentation should you need to make any changes to the file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Akka.Logger.Serilog:
| Package | Downloads |
|---|---|
|
SharpPulsar
SharpPulsar is Apache Pulsar Client built using Akka.net |
|
|
SnD.Sdk
SDK for Sneaks&Data OSS Projects |
|
|
EventSaucing
An event source stack based on NEventStore and Akka |
|
|
Cy.Bee.Core
Cy.Bee.Core assembles well-known packages for rapid application prototyping in contexts of Cyber Physical System (CPS). The Cy.Bee.Core rely on ReactiveX, EFCore and Akka.NET to create the basic functionalities for Cy.Bee. |
|
|
Cy.Bee.Testkit
Cy.Bee.Core assembles well-known packages for rapid application prototyping in contexts of Cyber Physical System (CPS). The Cy.Bee.Testkit re-models the behavior of xUnit to archieve sequencial test scenarios to maximize human-accessiblity. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.5.69 | 863 | 6/17/2026 |
| 1.5.67 | 25,177 | 4/28/2026 |
| 1.5.63 | 24,481 | 3/24/2026 |
| 1.5.60 | 46,485 | 2/10/2026 |
| 1.5.59 | 20,057 | 1/27/2026 |
| 1.5.58 | 31,096 | 1/9/2026 |
| 1.5.25 | 904,315 | 6/17/2024 |
| 1.5.12.1 | 398,213 | 9/14/2023 |
| 1.5.12 | 14,531 | 8/31/2023 |
| 1.5.7 | 276,902 | 5/19/2023 |
| 1.5.0.1 | 66,247 | 3/15/2023 |
| 1.5.0 | 37,064 | 3/2/2023 |
| 1.5.0-beta5 | 465 | 3/1/2023 |
| 1.4.42 | 247,612 | 9/23/2022 |
| 1.4.26 | 449,744 | 10/7/2021 |
| 1.4.25 | 17,254 | 9/9/2021 |
| 1.4.17 | 162,556 | 3/17/2021 |
| 1.4.11 | 248,209 | 11/7/2020 |
| 1.4.10 | 12,362 | 10/28/2020 |
| 1.4.8 | 110,712 | 7/1/2020 |
* [Update Akka.NET to 1.5.69](https://github.com/akkadotnet/akka.net/releases/tag/1.5.69)
* [Update Akka.Hosting to 1.5.69](https://github.com/akkadotnet/Akka.Hosting/releases/tag/1.5.69)
* [Fix incorrect WithLogging API reference in docs (should be ConfigureLoggers)](https://github.com/akkadotnet/Akka.Logger.Serilog/pull/343)