From 46569d56d32aa36299435c84a4e1b0bde69082e5 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 18 Nov 2022 13:10:45 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BB=D0=B0=D0=B6=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BB=D0=BE=D0=B3=D0=BE?= =?UTF-8?q?=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/Airbus.csproj | 1 + Airbus/Airbus/Program.cs | 23 +++++++--------- Airbus/Airbus/appsettings.json | 48 ---------------------------------- 3 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 Airbus/Airbus/appsettings.json 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 @@ + \ 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() - .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(); - 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