diff --git a/AccordionBus/AccordionBus/AccordionBus.csproj b/AccordionBus/AccordionBus/AccordionBus.csproj index f4009d4..f29b6a2 100644 --- a/AccordionBus/AccordionBus/AccordionBus.csproj +++ b/AccordionBus/AccordionBus/AccordionBus.csproj @@ -9,6 +9,9 @@ + + + diff --git a/AccordionBus/AccordionBus/Program.cs b/AccordionBus/AccordionBus/Program.cs index 528134f..c6856c2 100644 --- a/AccordionBus/AccordionBus/Program.cs +++ b/AccordionBus/AccordionBus/Program.cs @@ -1,6 +1,8 @@ +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Serilog; +using Serilog.Events; namespace AccordionBus { @@ -24,14 +26,14 @@ namespace AccordionBus private static void ConfigureServices(ServiceCollection services) { services.AddSingleton() - .AddLogging(option => option.AddSerilog(dispose: true)); - - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Debug() - .WriteTo.File("C:\\my\\ 1 2\\ \\log.txt") - .CreateLogger(); + .AddLogging(option => { + option.SetMinimumLevel(LogLevel.Debug); + option.AddSerilog(new LoggerConfiguration() + .ReadFrom.Configuration(new ConfigurationBuilder() + .AddJsonFile("C:\\my\\ 1 2\\ \\simple\\AccordionBus\\AccordionBus\\serilog.json") + .Build()) + .CreateLogger()); + }); } - - } } \ No newline at end of file diff --git a/AccordionBus/AccordionBus/serilog.json b/AccordionBus/AccordionBus/serilog.json new file mode 100644 index 0000000..69abef3 --- /dev/null +++ b/AccordionBus/AccordionBus/serilog.json @@ -0,0 +1,18 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "C:\\my\\курс 1 сим 2\\для ООП\\log.txt", + "outputTemplate": "[{Level:u}] [{Timestamp:yyyy-MM-dd HH:mm:ss.ffff}] {Message:1j}{NewLine}{Exception}" + } + } + ], + "Properties": { + "Application": "Sample" + } + } +} \ No newline at end of file