This repository has been archived by the owner on Nov 10, 2022. It is now read-only.
generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
executable file
·59 lines (52 loc) · 2.04 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Esquire.Data;
using Serilog;
using Serilog.Events;
namespace Esquire
{
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.File((System.IO.Path.Combine ("logs/esquire-.log")),
outputTemplate: "{Timestamp:o} {RequestId,13} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
rollingInterval: RollingInterval.Day,
fileSizeLimitBytes: 30_000_000,
rollOnFileSizeLimit: true)
.CreateLogger();
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope()) {
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<ProjectContext>();
DbInitializer.Initialize(context);
}
catch (Exception ex)
{
Console.WriteLine("Failed to get DbContext ProjectContext.");
Console.WriteLine(ex);
}
}
host.Run();
}
public static IWebHost BuildWebHost(string[] args){
var configuration = new ConfigurationBuilder().AddCommandLine(args).Build();
return WebHost.CreateDefaultBuilder(args)
.UseConfiguration(configuration)
.UseStartup<Startup>()
.UseSerilog()
.Build();
}
}
}