Bondarenko M.S. Lab Work 7 #14

Closed
maxnes3 wants to merge 8 commits from LabWork_07 into LabWork_06
2 changed files with 17 additions and 7 deletions
Showing only changes of commit 0a4cfe48c3 - Show all commits

View File

@ -26,14 +26,19 @@ namespace WarmlyShip
private static void ConfigureServices(ServiceCollection services)
{
services.AddSingleton<FormMapWithSetShip>();
var serilogLogger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger();
services.AddLogging(builder =>
services.AddSingleton<FormMapWithSetShip>().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);
});
}
}

View File

@ -19,11 +19,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Settings.Delegates" Version="1.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>