From 0a4cfe48c337ee1c4f996b4fa58ff8f286d20975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Thu, 1 Dec 2022 22:53:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20pull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/Program.cs | 19 ++++++++++++------- WarmlyShip/WarmlyShip/WarmlyShip.csproj | 5 +++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/WarmlyShip/WarmlyShip/Program.cs b/WarmlyShip/WarmlyShip/Program.cs index 6968d22..8f659fc 100644 --- a/WarmlyShip/WarmlyShip/Program.cs +++ b/WarmlyShip/WarmlyShip/Program.cs @@ -26,14 +26,19 @@ namespace WarmlyShip private static void ConfigureServices(ServiceCollection services) { - services.AddSingleton(); - - var serilogLogger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); - - services.AddLogging(builder => + services.AddSingleton().AddLogging(option => { - builder.SetMinimumLevel(LogLevel.Information); - builder.AddSerilog(logger: serilogLogger, dispose: true); + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true) + .Build(); + + var logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + option.SetMinimumLevel(LogLevel.Information); + option.AddSerilog(logger); }); } } diff --git a/WarmlyShip/WarmlyShip/WarmlyShip.csproj b/WarmlyShip/WarmlyShip/WarmlyShip.csproj index 316facb..62b17eb 100644 --- a/WarmlyShip/WarmlyShip/WarmlyShip.csproj +++ b/WarmlyShip/WarmlyShip/WarmlyShip.csproj @@ -19,11 +19,16 @@ + + + + +