From d18cbcd248773216510c4f25855c4460f609e7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Thu, 24 Nov 2022 18:40:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotives/Locomotives/Locomotives.csproj | 19 +++++++++++++++++++ Locomotives/Locomotives/Program.cs | 8 +++++++- Locomotives/Locomotives/appconfig.json | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Locomotives/Locomotives/appconfig.json diff --git a/Locomotives/Locomotives/Locomotives.csproj b/Locomotives/Locomotives/Locomotives.csproj index d79edaa..66f3144 100644 --- a/Locomotives/Locomotives/Locomotives.csproj +++ b/Locomotives/Locomotives/Locomotives.csproj @@ -8,6 +8,16 @@ enable + + + + + + + Always + + + True @@ -28,9 +38,18 @@ + + + + + + + + + diff --git a/Locomotives/Locomotives/Program.cs b/Locomotives/Locomotives/Program.cs index 04bdb50..5c76eb5 100644 --- a/Locomotives/Locomotives/Program.cs +++ b/Locomotives/Locomotives/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.Extensions.Configuration; using Serilog; namespace Locomotives @@ -10,9 +11,14 @@ namespace Locomotives [STAThread] static void Main() { + var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appconfig.json") + .AddJsonFile($"appconfig.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true) + .Build(); var Logger = new LoggerConfiguration() .MinimumLevel.Information() - .WriteTo.File(path: "log.txt", outputTemplate: "[{Timestamp:HH:mm:ss.fff}] {Level}: {Message};{NewLine}") + .ReadFrom.Configuration(configuration) .CreateLogger(); ApplicationConfiguration.Initialize(); Application.Run(new FormMapWithSetLocomotives(Logger)); diff --git a/Locomotives/Locomotives/appconfig.json b/Locomotives/Locomotives/appconfig.json new file mode 100644 index 0000000..b8a1b62 --- /dev/null +++ b/Locomotives/Locomotives/appconfig.json @@ -0,0 +1,17 @@ +{ + "Serilog": + { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Information", + "WriteTo": [ + { + "Name": "File", + "Args": + { + "path": "Logs/log.log", + "outputTemplate": "[{Timestamp:HH:mm:ss.fff}] {Level}: {Message};{NewLine}" + } + } + ] + } +} \ No newline at end of file