Skip to content

Instantly share code, notes, and snippets.

@otienoelvis
Created August 13, 2023 11:46
Show Gist options
  • Save otienoelvis/7b0ab36a07cd61cc373afcce017c6345 to your computer and use it in GitHub Desktop.
Save otienoelvis/7b0ab36a07cd61cc373afcce017c6345 to your computer and use it in GitHub Desktop.
Program.cs
using Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog((ctx, cfg) => cfg
.WriteTo.Console()
.ReadFrom.Configuration(ctx.Configuration));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSerilogRequestLogging();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment