diff --git a/ProjectExcavator/ProjectExcavator/Program.cs b/ProjectExcavator/ProjectExcavator/Program.cs
index 3e8ae08..9cdfe6c 100644
--- a/ProjectExcavator/ProjectExcavator/Program.cs
+++ b/ProjectExcavator/ProjectExcavator/Program.cs
@@ -1,7 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
-using NLog.Extensions.Logging;
+using Serilog;
namespace ProjectExcavator
{
@@ -29,10 +29,21 @@ namespace ProjectExcavator
///
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/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj
index 3f8ab34..2788a02 100644
--- a/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj
+++ b/ProjectExcavator/ProjectExcavator/ProjectExcavator.csproj
@@ -9,8 +9,16 @@
+
+
+
+
+
+
+
+
diff --git a/ProjectExcavator/ProjectExcavator/serilog.json b/ProjectExcavator/ProjectExcavator/serilog.json
new file mode 100644
index 0000000..a7878e1
--- /dev/null
+++ b/ProjectExcavator/ProjectExcavator/serilog.json
@@ -0,0 +1,15 @@
+{
+ "Serilog": {
+ "Using": [ "Serilog.Sinks.File" ],
+ "MinimumLevel": "Debug",
+ "WriteTo": [
+ {
+ "Name": "File",
+ "Args": { "path": "log.log" }
+ }
+ ],
+ "Properties": {
+ "Application": "Sample"
+ }
+ }
+}