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 @@ + + + + +