public static int Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .Filter.ByExcluding((logEvent) => logEvent.MessageTemplate.Text.Contains("Source:")) .WriteTo.File( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", $"log_{DateTime.UtcNow.ToString("yyyy _ MM _ dd _ HH _ mm _ ss _ fffffff").Replace(" ", string.Empty)}_UTC.txt"), restrictedToMinimumLevel: LogEventLevel.Information, fileSizeLimitBytes: 5_000_000, rollOnFileSizeLimit: true ) .CreateLogger(); try { Log.Information("Starting web host..."); var host = CreateHostBuilder(args).Build(); DatabaseLogic.Initialize <PromoCodesAspNetCoreWebApiDbContext>(host.Services); host.Run(); return(0); } catch (Exception ex) { Log.Fatal(ex, "Host terminated unexpectedly"); return(1); } finally { Log.CloseAndFlush(); } }