Using Serilog with ASP.NET Core 6 - Logging Structure optimization guide as Expected
I've looked through the documentation and I'm still confused about I'm currently working on an ASP.NET Core 6 application and trying to implement structured logging using Serilog. However, I've encountered an scenario where the output logs do not show the expected structured data. Since I'm using a SQL Server sink, I'm expecting the logs to include properties like `UserId` and `RequestId`. Hereβs the configuration I have in my `Program.cs`: ```csharp var builder = WebApplication.CreateBuilder(args); builder.Host.UseSerilog((context, services, config) => config .ReadFrom.Configuration(context.Configuration) .Enrich.WithProperty("ApplicationName", "MyApp") .Enrich.FromLogContext()); ``` In my controller, I'm trying to log an event like this: ```csharp _logger.LogInformation("User {UserId} made a request with id {RequestId}", userId, requestId); ``` But when I check the logs in my SQL Server database, the log entries do not contain the `UserId` and `RequestId` properties; they appear only as a message string without any additional structured data. I've validated that `Serilog.AspNetCore` and `Serilog.Sinks.MSSqlServer` packages are correctly installed with versions 6.0.0 and 5.6.0 respectively. I've also confirmed that the logging level is set to Information in the `appsettings.json`. I've tried reformatting the logging statements, but the scenario continues. The SQL table structure seems correct as well, with the appropriate columns for the properties I'm logging. Am I missing something in the configuration or usage of Serilog? Is there any additional setup required to ensure that structured logging works properly? I'm working on a CLI tool that needs to handle this. What's the best practice here? Any examples would be super helpful.