After upgrading to Akka .Net 1.5 we seem to have lost our semantic properties. I followed this guide to fix it: https://getakka.net/articles/utilities/serilog.html
However it seems to have no effect. The logs are coming through without the additional properties.
Our Serilog is assigned after it is configured in our application:
Log.Logger = config.CreateLogger();
And I can confirm this config is used since I can see application insights logs. However the logs always come through in the same incorrect way without additional properties.
{
"name": "AppTraces",
"time": "2023-05-11T09:01:21.9089715Z",
"data": {
"baseType": "MessageData",
"baseData": {
"ver": 2,
"message": "Doing a thing on a log \"MyExtraPropValue\"",
"severityLevel": "Information",
"properties": {
"LogSource": "[akka://my-actor-system/user/my-actor#1234344381]",
"Timestamp": "2023-05-11T09:01:21.9089046Z",
"Message": "Doing a thing on a log \"MyExtraPropValue\"",
"Thread": "0044",
"SourceContext": "MyProject.MyActorClass",
"MessageTemplate": "{Message:l}",
"ActorPath": "akka://my-actor-system/user/my-actor"
}
}
}
}
The call to initialize the logger as a field in the actor looks like this:
private readonly ILoggingAdapter _logger = Context.GetLogger<SerilogLoggingAdapter>();
The call somewhere in my actor's receive looks like this.
_logger.Info("Doing a thing on a log '{MyExtraPropName}'", "MyExtraPropValue");
This is the content of our HOCON file
akka
{
loglevel=INFO
log-dead-letters = off
log-dead-letters-during-shutdown = off
loggers=["Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog"]
logger-formatter="Akka.Logger.Serilog.SerilogLogMessageFormatter, Akka.Logger.Serilog"
actor {
ask-timeout = 60s
}
}
One of the breaking changes introduced in Akka 1.5 is the addition of custom log message formatter, and this apparently is not compatible with the old serilog logging flow. We will try and fix this in future releases.
In the mean time, a workaround is:
Akka.Logger.Serilog
version is at least 1.5.0.1 (as of this writing)akka.logger-formatter
to "Akka.Logger.Serilog.SerilogLogMessageFormatter, Akka.Logger.Serilog"
Context.GetLogger<SerilogLoggingAdapter>()
to retrieve an ILoggingAdapter
reference, use Context.GetLogger()
instead.