-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
54 lines (50 loc) · 1.54 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
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Serilog;
using dotenv.net;
namespace SearchEngine
{
/// <summary>
/// The entry point for the application.
/// </summary>
public class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
/// <param name="args">Command-line arguments.</param>
public static void Main(string[] args)
{
// Configure Serilog for logging
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
try
{
Log.Information("Starting up the host...");
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}
/// <summary>
/// Creates and configures a <see cref="IHostBuilder"/> for the application.
/// </summary>
/// <param name="args">Command-line arguments.</param>
/// <returns>An <see cref="IHostBuilder"/> instance.</returns
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
}