-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
ASP.NET Core 9 Web API Cookbook
By :
ASP.NET Core’s HttpLogging is a middleware provided by Microsoft that automatically logs information about HTTP requests and responses. Introduced with .NET 8, HttpLogging tends to be quite verbose by default. In this recipe, we will customize HttpLogging and combine it effectively with the Serilog logging middleware.
To achieve this, we will utilize HttpLogging’s CombineLogs property, which consolidates all enabled logs for a request and response into a single log entry at the end of the request. We will also use the LoggingFields property to precisely control what information is logged. Additionally, we’ll demonstrate how to adjust logging verbosity based on the environment (development versus production) to manage log volume effectively.
By combining HttpLogging with Serilog, we can leverage the detailed HTTP information capture of HttpLogging with the powerful...