@@ -147,7 +147,7 @@ builder
147147var app = builder .Build ();
148148
149149app
150- .UseRequestResponseLogging ()
150+ .UseRequestLogging ()
151151 .UseResponseCrafter ()
152152 .UseCors ()
153153 .MapMinimalApis ()
@@ -253,7 +253,8 @@ Add the following configuration to your `appsettings.json` file:
253253Based on the above configuration, the UI will be accessible at the following URLs:
254254
255255- ** Swagger (all documents):** [ http://localhost/swagger ] ( http://localhost/swagger )
256- - ** Swagger (external document only):** [ http://localhost/swagger/integration-v1 ] ( http://localhost/swagger/integration-v1 )
256+ - ** Swagger (external document only):
257+ ** [ http://localhost/swagger/integration-v1 ] ( http://localhost/swagger/integration-v1 )
257258- ** Scalar (admin document):** [ http://localhost/scalar/admin-v1 ] ( http://localhost/scalar/admin-v1 )
258259- ** Scalar (integration document):** [ http://localhost/scalar/integration-v1 ] ( http://localhost/scalar/integration-v1 )
259260
@@ -266,9 +267,8 @@ Based on the above configuration, the UI will be accessible at the following URL
266267 Development, Production).
267268- ** Elastic Common Schema Formatting:** Logs are formatted using the Elastic Common Schema (ECS) for compatibility with
268269 Elasticsearch.
269- - ** Request and Response Logging Middleware:** Middleware that logs incoming requests and outgoing responses while
270- redacting
271- sensitive information.
270+ - ** Request Logging Middleware:** Middleware that logs incoming requests and outgoing responses while redacting
271+ sensitive information and 5kb exceeding properties.
272272- ** Log Filtering:** Excludes unwanted logs from Hangfire Dashboard, Swagger, and outbox database commands.
273273- ** Distributed:** Designed to work with distributed systems and microservices.
274274
@@ -285,7 +285,7 @@ In your middleware pipeline, add the request and response logging middleware:
285285
286286``` csharp
287287var app = builder .Build ();
288- app .UseRequestResponseLogging ();
288+ app .UseRequestLogging ();
289289```
290290
291291In your ` appsettings.{Environment}.json ` configure ` Serilog ` .
@@ -337,12 +337,39 @@ builder.LogStartAttempt();
337337// Configure services
338338var app = builder .Build ();
339339// Configure middleware
340- app .UseRequestResponseLogging ();
340+ app .UseRequestLogging ();
341341// Other middleware
342342app .LogStartSuccess ();
343343app .Run ();
344344```
345345
346+ ### Outbound Logging with HttpClient
347+
348+ In addition to the ` RequestLoggingMiddleware ` for inbound requests, you can now log ** outbound** HTTP calls via an
349+ ` OutboundLoggingHandler ` . This handler captures request and response data (including headers and bodies), automatically
350+ redacting sensitive information (e.g., passwords, tokens).
351+
352+ #### Usage
353+
354+ 1 . ** Register the handler** in your ` WebApplicationBuilder ` :
355+ ``` csharp
356+ builder .AddOutboundLoggingHandler ();
357+ ```
358+ 2 . ** Attach** the handler to any HttpClient registration:
359+ ``` csharp
360+ builder .Services
361+ .AddHttpClient (" RandomApiClient" , client =>
362+ {
363+ client .BaseAddress = new Uri (" http://localhost" );
364+ })
365+ .AddOutboundLoggingHandler ();
366+ ```
367+ 3 . ** Check logs : ** Outbound requests and responses are now logged with redacted headers and bodies , just like inbound
368+ traffic .
369+
370+ > Note : The same redaction rules apply to inbound and outbound calls . Update RedactionHelper if you need to modify the
371+ > behavior (e .g ., adding new sensitive keywords ).
372+
346373## MediatR and FluentValidation Integration
347374
348375### Key Features
@@ -543,7 +570,8 @@ Integrate OpenTelemetry for observability, including metrics, traces, and loggin
543570 - Health Metrics : `url / above - board / prometheus / health `
544571
5455723 . OTLP Configuration :
546- To configure the OTLP exporter , ensure the following entries are present in your appsettings {Environment }.json or as environment variables :
573+ To configure the OTLP exporter , ensure the following entries are present in your appsettings {Environment }.json or as
574+ environment variables :
547575 ```json
548576 {
549577 " OTEL_EXPORTER_OTLP_ENDPOINT" : " http://localhost:4317"
0 commit comments