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