From 223fb48e6c17ef92da74384b1ca3b824addd3320 Mon Sep 17 00:00:00 2001 From: Vladimir Pecanac Date: Mon, 24 Aug 2026 00:26:04 +0200 Subject: [PATCH] UsingSerilogWithMicrosoftILogger: retarget net10.0, add request logging Retarget both projects to net10.0. Bump Serilog.AspNetCore 8.0.1 -> 10.0.0 and Swashbuckle.AspNetCore 6.4.0 -> 10.2.3 so the sample restores on the current SDK. Add UseSerilogRequestLogging() to the pipeline plus the Microsoft.AspNetCore minimum-level override the Serilog.AspNetCore readme recommends, so a request produces one summary event instead of seven framework events. --- .../UsingSerilogWithMicrosoftILogger/Tests/Tests.csproj | 2 +- .../UsingSerilogWithMicrosoftILogger/Program.cs | 7 ++++++- .../UsingSerilogWithMicrosoftILogger.csproj | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dotnet-logging/UsingSerilogWithMicrosoftILogger/Tests/Tests.csproj b/dotnet-logging/UsingSerilogWithMicrosoftILogger/Tests/Tests.csproj index 633cde5260..a9858b3147 100644 --- a/dotnet-logging/UsingSerilogWithMicrosoftILogger/Tests/Tests.csproj +++ b/dotnet-logging/UsingSerilogWithMicrosoftILogger/Tests/Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net10.0 enable enable diff --git a/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/Program.cs b/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/Program.cs index c958221cd0..c7f184a802 100644 --- a/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/Program.cs +++ b/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/Program.cs @@ -1,10 +1,13 @@ using Serilog; +using Serilog.Events; var builder = WebApplication.CreateBuilder(args); builder.Host.UseSerilog((context, loggerConfiguration) => { - loggerConfiguration.WriteTo.Console(); + loggerConfiguration + .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) + .WriteTo.Console(); }); builder.Services.AddControllers(); @@ -18,6 +21,8 @@ app.UseSwaggerUI(); } +app.UseSerilogRequestLogging(); + app.UseAuthorization(); app.MapControllers(); diff --git a/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger.csproj b/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger.csproj index 830897cd95..980e5e01c5 100644 --- a/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger.csproj +++ b/dotnet-logging/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger/UsingSerilogWithMicrosoftILogger.csproj @@ -1,15 +1,15 @@ - net8.0 + net10.0 enable enable true - - + +