ASP.NET Core - Log both Request and Response using Middleware

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


For some time I've searched for the best way to log requests and response in an ASP.Net Core. I was developing services and one of the requirements was to record request with its response in one record the the database. So many topics out there but none worked for me. it's either for request only, response only or simply didn't work. When I was able to finally do it, and it had evolved during my project to better error handling and logging exceptions so I thought of sharing.


Got any Question?