diff --git a/ProjectBattleship/ProjectBattleship/Program.cs b/ProjectBattleship/ProjectBattleship/Program.cs
index cece054..e324fde 100644
--- a/ProjectBattleship/ProjectBattleship/Program.cs
+++ b/ProjectBattleship/ProjectBattleship/Program.cs
@@ -3,6 +3,8 @@ using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System.Drawing;
using System;
+using Microsoft.Extensions.Configuration;
+using Serilog;
namespace ProjectBattleship
{
@@ -29,11 +31,21 @@ namespace ProjectBattleship
///
private static void ConfigureServices(ServiceCollection services)
{
- services.AddSingleton()
- .AddLogging(option =>
+ services.AddSingleton().AddLogging(option =>
{
+ string[] path = Directory.GetCurrentDirectory().Split('\\');
+ string pathNeed = "";
+ for (int i = 0; i < path.Length - 3; i++)
+ {
+ pathNeed += path[i] + "\\";
+ }
+
+ var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
+ .AddJsonFile(path: $"{pathNeed}serilogConfig.json", optional: false, reloadOnChange: true)
+ .Build();
+ var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
option.SetMinimumLevel(LogLevel.Information);
- option.AddNLog("nlog.config");
+ option.AddSerilog(logger);
});
}
}
diff --git a/ProjectBattleship/ProjectBattleship/ProjectBattleship.csproj b/ProjectBattleship/ProjectBattleship/ProjectBattleship.csproj
index c760e16..6ae59a6 100644
--- a/ProjectBattleship/ProjectBattleship/ProjectBattleship.csproj
+++ b/ProjectBattleship/ProjectBattleship/ProjectBattleship.csproj
@@ -14,6 +14,8 @@
+
+
@@ -31,4 +33,10 @@
+
+
+ Always
+
+
+
\ No newline at end of file