public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() //possible to use appsettings .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .MinimumLevel.Override("System", LogEventLevel.Warning) .MinimumLevel.Override("Weather Service", LogEventLevel.Debug) .Enrich.FromLogContext() //.WriteTo.Console() .WriteTo.Console(new CompactJsonFormatter()) .WriteTo.File( $@"{AppDomain.CurrentDomain.BaseDirectory}/logs", fileSizeLimitBytes: 1_000_000, rollOnFileSizeLimit: true, shared: true, flushToDiskInterval: TimeSpan.FromSeconds(1)) .WriteTo.Seq("http://localhost:5341") .CreateLogger(); try { Log.Information("Starting web host"); CreateHostBuilder(args).Build().Run(); } catch (Exception e) { Log.Fatal(e, "Host terminated unexpectedly"); } finally { Log.CloseAndFlush(); } }
public static void ConfigureLogging(this IServiceCollection _) { Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Information() // .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) // .MinimumLevel.Override("System", LogEventLevel.Warning) .WriteTo.Console() # if DEBUG .WriteTo.Seq("http://localhost:5341") # endif .CreateLogger(); }