improved logging again

This commit is contained in:
Mark van der Wal 2021-04-19 14:03:43 +02:00
parent 1b6128f52a
commit e7de64d04c

View File

@ -59,11 +59,15 @@ namespace FarmmapsApi
private static void ConfigureLogger(IServiceProvider serviceProvider) private static void ConfigureLogger(IServiceProvider serviceProvider)
{ {
var isMicrosoftNamespace = Matching.FromSource("Microsoft"); var isMicrosoftNamespace = Matching.FromSource("Microsoft");
var isSystem = Matching.FromSource("System");
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information() .MinimumLevel.Verbose()
.WriteTo.Logger(l => l.Filter.ByIncludingOnly(isMicrosoftNamespace) .WriteTo.Logger(l =>
.WriteTo.Console(LogEventLevel.Warning)) l.WriteTo.Logger(l2 => l2
.Filter.ByExcluding(v => isMicrosoftNamespace(v) || isSystem(v))
.WriteTo.Console())
)
.WriteTo.File(path: "Logs/log.log", rollingInterval: RollingInterval.Day) .WriteTo.File(path: "Logs/log.log", rollingInterval: RollingInterval.Day)
.CreateLogger(); .CreateLogger();