Answers for "serilog-in-aspnetcore-3 sql server configuration"

SQL
0

serilog-in-aspnetcore-3 sql server configuration

public class Program
{
    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();
    public static void Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()            .ReadFrom.Configuration(Configuration)            .CreateLogger();
        try
        {
            Log.Information("Getting the motors running...");

            BuildWebHost(args).Run();
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "Host terminated unexpectedly");
        }
        finally
        {
            Log.CloseAndFlush();
        }
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
               .UseStartup<Startup>()
               .UseConfiguration(Configuration)
               .UseSerilog()               .Build();
}
Posted by: Guest on December-22-2020

Code answers related to "serilog-in-aspnetcore-3 sql server configuration"

Code answers related to "SQL"

Browse Popular Code Answers by Language