.NET HttpLogging of request to custom storage

Viewed 17

We work in .NET 6 and want to log all incoming requests. We plan to allow this primarily in DEV and TEST environments but potentially and temporarily also in PROD.

The new HttpLogger sounds like a perfect match. But it will output to the standard ILogger which in our case is Elastic. From GDPR reasons we want to avoid that where potentially sensitive data will be exposed in an uncontrolled way.

Does anyone have another solution:

  1. Redirect messages from HttpLogger to other storage
  2. Create custom middleware to be able to sniff requests and output to custom storage

I found this interesting post on reading the body twice but was not able to make it work: https://codetalk.in/posts/2022/01/04/read-request-body-multiple-times-in-asp-dot-net-core

0 Answers
Related