diff --git a/Airbus/Airbus/Airbus.csproj b/Airbus/Airbus/Airbus.csproj index 6a62cf2..8ea4f98 100644 --- a/Airbus/Airbus/Airbus.csproj +++ b/Airbus/Airbus/Airbus.csproj @@ -41,6 +41,7 @@ <PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> + <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" /> </ItemGroup> </Project> \ No newline at end of file diff --git a/Airbus/Airbus/Program.cs b/Airbus/Airbus/Program.cs index 16904b8..960b56d 100644 --- a/Airbus/Airbus/Program.cs +++ b/Airbus/Airbus/Program.cs @@ -30,21 +30,18 @@ namespace Airbus private static void ConfigureServices(ServiceCollection services) { - services.AddSingleton<FormMapWithSetPlanes>() - .AddLogging(option => - { - var configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile(path: "C:\\Users\\Programmist73\\Desktop\\��������\\2-� ����\\���\\Base\\PIbd-21_Eliseev_E.E._Airbus_Base\\Airbus\\Airbus\\appsettings.json", optional: false, reloadOnChange: true) - .Build(); + services.AddSingleton<FormMapWithSetPlanes>(); - var logger = new LoggerConfiguration() - .ReadFrom.Configuration(configuration) - .CreateLogger(); + var serilogLogger = new LoggerConfiguration() + .WriteTo.RollingFile("Logs\\log.txt") + .CreateLogger(); + + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddSerilog(logger: serilogLogger, dispose: true); + }); - option.SetMinimumLevel(LogLevel.Information); - option.AddSerilog(logger); - }); } } } \ No newline at end of file diff --git a/Airbus/Airbus/appsettings.json b/Airbus/Airbus/appsettings.json deleted file mode 100644 index bb6390d..0000000 --- a/Airbus/Airbus/appsettings.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "Serilog": { - "Using": [ "Serilog.Sinks.File" ], - "MinimumLevel": "Information", - "WriteTo": [ - { - "Name": "File", - "Args": { - "path": "Logs/log_.log", - "rollingInterval": "Day", - "outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}" - } - } - ], - "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], - "Destructure": [ - { - "Name": "ByTransforming", - "Args": { - "returnType": "Plane.EntityAirbus", - "transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }" - } - }, - { - "Name": "ByTransforming", - "Args": { - "returnType": "Plane.EntitySuperAirbus", - "transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor.Name, r.HasСompartment, r.HasEngine, r.Speed, r.Weight }" - } - }, - { - "Name": "ToMaximumDepth", - "Args": { "maximumDestructuringDepth": 4 } - }, - { - "Name": "ToMaximumStringLength", - "Args": { "maximumStringLength": 100 } - }, - { - "Name": "ToMaximumCollectionCount", - "Args": { "maximumCollectionCount": 10 } - } - ], - "Properties": { - "Application": "Airbus" - } - } -} \ No newline at end of file