1+ using Microsoft . AspNetCore . HttpLogging ;
12using Serilog ;
23using Serilog . Core ;
34using Serilog . Exceptions ;
@@ -46,12 +47,28 @@ private static async Task Main(string[] args)
4647 _ = ConfigureLogger ( options ) ;
4748 } ) ;
4849
49- _ = builder . Services . AddControllers ( ) ;
50+ var services = builder . Services ;
51+ _ = services . AddControllers ( ) ;
52+ _ = services . AddHttpContextAccessor ( ) ;
5053 // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
51- _ = builder . Services . AddOpenApi ( ) ;
54+ _ = services . AddOpenApi ( ) ;
55+
56+ _ = services
57+ . AddHttpLogging (
58+ ( options ) =>
59+ {
60+ options . LoggingFields = HttpLoggingFields . All ;
61+ } ) ;
62+
63+ _ = services . AddHealthChecks ( ) ;
5264
5365 var app = builder . Build ( ) ;
5466
67+ _ = app . UseForwardedHeaders ( ) ;
68+ _ = app . UseHttpsRedirection ( ) ;
69+
70+ _ = app . UseStaticFiles ( ) ;
71+
5572 // Configure the HTTP request pipeline.
5673 if ( app . Environment . IsDevelopment ( ) )
5774 {
@@ -63,6 +80,10 @@ private static async Task Main(string[] args)
6380 _ = app . UseHsts ( ) ;
6481 }
6582
83+ _ = app . UseHttpLogging ( ) ;
84+
85+ _ = app . UseHealthChecks ( "/health" ) ;
86+
6687 //_ = app.UseSerilogRequestLogging(
6788 // (options) =>
6889 // {
@@ -74,8 +95,6 @@ private static async Task Main(string[] args)
7495 // };
7596 // });
7697
77- _ = app . UseHttpsRedirection ( ) ;
78-
7998 _ = app . UseAuthorization ( ) ;
8099
81100 _ = app . MapControllers ( ) ;
0 commit comments