diff --git a/ProjectTrolleybus/ProjectTrolleybus/Program.cs b/ProjectTrolleybus/ProjectTrolleybus/Program.cs
index 4027b76..b2dec97 100644
--- a/ProjectTrolleybus/ProjectTrolleybus/Program.cs
+++ b/ProjectTrolleybus/ProjectTrolleybus/Program.cs
@@ -1,7 +1,8 @@
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using NLog.Extensions.Logging;
+using Serilog;
namespace ProjectTrolleybus
@@ -29,10 +30,21 @@ namespace ProjectTrolleybus
///
private static void ConfigureServices(ServiceCollection services)
{
- services.AddSingleton().AddLogging(option =>
+ string[] path = Directory.GetCurrentDirectory().Split('\\');
+ string pathNeed = "";
+ for (int i = 0; i < path.Length - 3; i++)
+ {
+ pathNeed += path[i] + "\\";
+ }
+ services.AddSingleton()
+ .AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
- option.AddNLog("nlog.config");
+ option.AddSerilog(new LoggerConfiguration()
+ .ReadFrom.Configuration(new ConfigurationBuilder()
+ .AddJsonFile($"{pathNeed}serilog.json")
+ .Build())
+ .CreateLogger());
});
}
}
diff --git a/ProjectTrolleybus/ProjectTrolleybus/ProjectTrolleybus.csproj b/ProjectTrolleybus/ProjectTrolleybus/ProjectTrolleybus.csproj
index 5f546b7..349d6dd 100644
--- a/ProjectTrolleybus/ProjectTrolleybus/ProjectTrolleybus.csproj
+++ b/ProjectTrolleybus/ProjectTrolleybus/ProjectTrolleybus.csproj
@@ -9,8 +9,16 @@
+
+
+
+
+
+
+
+
diff --git a/ProjectTrolleybus/ProjectTrolleybus/serilog.json b/ProjectTrolleybus/ProjectTrolleybus/serilog.json
new file mode 100644
index 0000000..21a6582
--- /dev/null
+++ b/ProjectTrolleybus/ProjectTrolleybus/serilog.json
@@ -0,0 +1,15 @@
+{
+ "Serilog": {
+ "Using": [ "Serilog.Sinks.File" ],
+ "MinimumLevel": "Debug",
+ "WriteTo": [
+ {
+ "Name": "File",
+ "Args": { "path": "log.log" }
+ }
+ ],
+ "Properties": {
+ "Application": "Sample"
+ }
+ }
+}
\ No newline at end of file