diff --git a/FarmmapsApi/FarmmapsApi.csproj b/FarmmapsApi/FarmmapsApi.csproj
index 8f133f8..46a26b6 100644
--- a/FarmmapsApi/FarmmapsApi.csproj
+++ b/FarmmapsApi/FarmmapsApi.csproj
@@ -6,13 +6,15 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/FarmmapsApi/FarmmapsProgram.cs b/FarmmapsApi/FarmmapsProgram.cs
index b1bc874..cc9ba5a 100644
--- a/FarmmapsApi/FarmmapsProgram.cs
+++ b/FarmmapsApi/FarmmapsProgram.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net.Http;
using System.Threading.Tasks;
using FarmmapsApi.HttpMessageHandlers;
@@ -6,6 +7,10 @@ using FarmmapsApi.Services;
using IdentityModel.Client;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Serilog;
+using Serilog.Events;
+using Serilog.Filters;
namespace FarmmapsApi
{
@@ -37,10 +42,12 @@ namespace FarmmapsApi
.AddHttpMessageHandler()
.Services;
-
Configure(serviceCollection);
var serviceProvider = serviceCollection.BuildServiceProvider();
+
+ ConfigureLogger(serviceProvider);
+
await serviceProvider.GetService().AuthenticateAsync();
// await serviceProvider.GetService().StartEventHub();
@@ -48,5 +55,20 @@ namespace FarmmapsApi
}
protected abstract void Configure(IServiceCollection serviceCollection);
+
+ private static void ConfigureLogger(IServiceProvider serviceProvider)
+ {
+ var isService = Matching.FromSource("Microsoft");
+
+ Log.Logger = new LoggerConfiguration()
+ .MinimumLevel.Information()
+ .WriteTo.Logger(l => l.Filter.ByIncludingOnly(isService)
+ .WriteTo.Console(LogEventLevel.Warning))
+ .WriteTo.File(path: "Logs/log.log", rollingInterval: RollingInterval.Day)
+ .CreateLogger();
+
+ var loggerFactory = serviceProvider.GetRequiredService();
+ loggerFactory.AddSerilog();
+ }
}
}
\ No newline at end of file
diff --git a/FarmmapsPoten/Program.cs b/FarmmapsPoten/Program.cs
index a3fa657..f9bcb48 100644
--- a/FarmmapsPoten/Program.cs
+++ b/FarmmapsPoten/Program.cs
@@ -14,9 +14,7 @@ namespace FarmmapsVRApoten
protected override void Configure(IServiceCollection serviceCollection)
{
- serviceCollection.AddLogging(opts => opts
- .AddConsole()
- .AddFilter("System.Net.Http", LogLevel.Warning))
+ serviceCollection.AddLogging()
.AddTransient();
}
}