1
|
using Serilog;
|
2
|
|
3
|
var builder = WebApplication.CreateBuilder(args);
|
4
|
|
5
|
// Logging
|
6
|
builder.Host.UseSerilog((ctx, lc) => lc.WriteTo.Console());
|
7
|
|
8
|
builder.Services.AddControllers();
|
9
|
|
10
|
// Swagger
|
11
|
builder.Services.AddEndpointsApiExplorer();
|
12
|
builder.Services.AddSwaggerGen();
|
13
|
|
14
|
var app = builder.Build();
|
15
|
|
16
|
// Configure the HTTP request pipeline.
|
17
|
if (app.Environment.IsDevelopment())
|
18
|
{
|
19
|
app.UseSwagger();
|
20
|
app.UseSwaggerUI();
|
21
|
}
|
22
|
|
23
|
app.UseHttpsRedirection();
|
24
|
app.UseAuthorization();
|
25
|
|
26
|
app.MapControllers();
|
27
|
|
28
|
// Logging
|
29
|
app.UseSerilogRequestLogging();
|
30
|
app.Logger.LogInformation("Starting up");
|
31
|
|
32
|
app.Run();
|