From 387f831dbdf8b4879a4eb3719621cd63100d60f8 Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:13:32 +0200 Subject: [PATCH] test: update example to .NET 8 --- examples/Serilog/Client/Client.csproj | 8 ++++---- examples/Serilog/Service/Program.cs | 17 ++++++++++------- examples/Serilog/Service/Service.csproj | 6 +++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/examples/Serilog/Client/Client.csproj b/examples/Serilog/Client/Client.csproj index b7b550c..fe0c934 100644 --- a/examples/Serilog/Client/Client.csproj +++ b/examples/Serilog/Client/Client.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 @@ -18,9 +18,9 @@ - - - + + + diff --git a/examples/Serilog/Service/Program.cs b/examples/Serilog/Service/Program.cs index 03ba23f..947e314 100644 --- a/examples/Serilog/Service/Program.cs +++ b/examples/Serilog/Service/Program.cs @@ -4,13 +4,16 @@ WebApplicationBuilder builder = WebApplication.CreateBuilder(args); -builder.WebHost - .UseSerilog((ctx, loggerConfig) => loggerConfig - .ReadFrom.Configuration(ctx.Configuration) - .Enrich.FromLogContext() - // Add the property to the template explicitly, or log all properties with {Properties}. - .WriteTo.Console(outputTemplate: "Message: {Message:lj}{NewLine}\tCorrelation ID: {CorrelationId}{NewLine}") - .WriteTo.Debug() +builder.Services + .AddLogging(configure => configure.AddSerilog( + new LoggerConfiguration() + .ReadFrom.Configuration(builder.Configuration) + .Enrich.FromLogContext() + // Add the property to the template explicitly, or log all properties with {Properties}. + .WriteTo.Console(outputTemplate: "Message: {Message:lj}{NewLine}\tCorrelation ID: {CorrelationId}{NewLine}") + .WriteTo.Debug() + .CreateLogger() + ) ); builder.Services diff --git a/examples/Serilog/Service/Service.csproj b/examples/Serilog/Service/Service.csproj index b26d256..6c63e86 100644 --- a/examples/Serilog/Service/Service.csproj +++ b/examples/Serilog/Service/Service.csproj @@ -1,12 +1,12 @@  - net7.0 + net8.0 - - + +