serilog in aspnetcore 3 sql server configuration

Solutions on MaxInterview for serilog in aspnetcore 3 sql server configuration by the best coders in the world

showing results for - "serilog in aspnetcore 3 sql server configuration"
Matilda
30 Jul 2018
1public class Program
2{
3    public static IConfiguration Configuration { get; } = new ConfigurationBuilder()        .SetBasePath(Directory.GetCurrentDirectory())        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)        .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", optional: true)        .Build();
4    public static void Main(string[] args)
5    {
6        Log.Logger = new LoggerConfiguration()            .ReadFrom.Configuration(Configuration)            .CreateLogger();
7        try
8        {
9            Log.Information("Getting the motors running...");
10
11            BuildWebHost(args).Run();
12        }
13        catch (Exception ex)
14        {
15            Log.Fatal(ex, "Host terminated unexpectedly");
16        }
17        finally
18        {
19            Log.CloseAndFlush();
20        }
21    }
22
23    public static IWebHost BuildWebHost(string[] args) =>
24        WebHost.CreateDefaultBuilder(args)
25               .UseStartup<Startup>()
26               .UseConfiguration(Configuration)
27               .UseSerilog()               .Build();
28}