'Serilog logging to Azure eventhub stopped working after moving project to .Net Core 5
I have a .Net Core 3.1 project that uses Serilog and posts messages to Azure Eventhub. The problems started when we moved it to .Net 5.
Here's how it's configured in Startup.cs in ConfigureServices we have section
var eventHubConfig = Configuration.GetSection("Logging").GetSection("eventHub");
string eventHubConnection = eventHubConfig.GetValue<string>("connectionString");
Log.Logger = new LoggerConfiguration()
.WriteTo.AzureEventHub(new JsonFormatter(),
eventHubConnection.Replace(@"\", ""),
eventHubConfig.GetValue<string>("entityName"))
.CreateLogger();
in Configure method we have: loggerFactory.AddSerilog();
and in Program.cs
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSerilog()
.UseStartup<Startup>();
Very simple and it's working for .Net Core 3.1, but once I change the target framework for the project to .Net 5 it stops working.
Any thoughts? Has anyone seen the same issue?
Solution 1:[1]
Serilog uses an old version of Microsoft.Azure.EventHubs internally
I had the same issue and bumping to 4.3.2 solved the problem
Since then Microsoft.Azure.EventHubs have been deprecated and we have moved to Serilog 6 and Azure.Messaging.EventHubs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kristoffer Vidmo |