Fermat.EntityFramework.HttpRequestLogs 0.0.1

dotnet add package Fermat.EntityFramework.HttpRequestLogs --version 0.0.1
                    
NuGet\Install-Package Fermat.EntityFramework.HttpRequestLogs -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fermat.EntityFramework.HttpRequestLogs" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fermat.EntityFramework.HttpRequestLogs" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Fermat.EntityFramework.HttpRequestLogs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fermat.EntityFramework.HttpRequestLogs --version 0.0.1
                    
#r "nuget: Fermat.EntityFramework.HttpRequestLogs, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fermat.EntityFramework.HttpRequestLogs@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fermat.EntityFramework.HttpRequestLogs&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Fermat.EntityFramework.HttpRequestLogs&version=0.0.1
                    
Install as a Cake Tool

Fermat.EntityFramework.HttpRequestLogs

Fermat.EntityFramework.HttpRequestLogs is a comprehensive HTTP request logging library for .NET applications that provides detailed tracking of HTTP requests, performance metrics, and request analysis. It's built on top of Entity Framework Core and follows clean architecture principles.

Features

  • Detailed HTTP request and response logging
  • Performance metrics tracking
  • Client device and browser information
  • Request rate analysis
  • Response time statistics
  • Error rate monitoring
  • Endpoint performance analysis
  • Client usage statistics
  • Configurable sensitive data masking
  • Flexible request filtering
  • Automatic cleanup of old logs

Installation

  dotnet add package Fermat.EntityFramework.HttpRequestLogs

Project Structure

The library follows Clean Architecture principles with the following layers:

Core

  • Base entities and interfaces
  • Domain models
  • Enums and constants
  • Configuration options

Infrastructure

  • Entity Framework Core configurations
  • Database context implementations
  • Repository implementations

Application

  • DTOs
  • Interfaces
  • Services
  • Mappings

Presentation

  • Controllers
  • API endpoints
  • Request/Response models

DependencyInjection

  • Service registration extensions
  • Configuration options
  • Middleware implementation

Configuration

// Configure HTTP request logging in Startup.cs
builder.Services.AddFermatHttpRequestLogServices<ApplicationDbContext>(opt =>
{
    // Enable/Disable request logging
    opt.Enabled = true;

    // Configure path exclusions
    opt.ExcludedPaths = ["/health", "/metrics", "/favicon.ico"];
    opt.ExcludedHttpMethods = ["OPTIONS"];
    opt.ExcludedContentTypes = ["application/octet-stream", "application/pdf", "image/", "video/", "audio/"];

    // Configure request body logging
    opt.LogRequestBody = true;
    opt.MaxRequestBodyLength = 5000;
    opt.LogOnlySlowRequests = true;
    opt.SlowRequestThresholdMs = 10;

    // Configure sensitive data masking
    opt.MaskPattern = "***MASKED***";
    opt.RequestBodySensitiveProperties = [
        "Password", "Token", "Secret", "Key", "Credential", 
        "Ssn", "Credit", "Card", "Description"
    ];
    opt.QueryStringSensitiveProperties = [
        "Password", "Token", "Secret", "ApiKey", "Key"
    ];
    opt.HeaderSensitiveProperties = [
        "Authorization", "Cookie", "X-Api-Key"
    ];
});

// Configure DbContext
public class YourDbContext : DbContext 
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        
        // Apply HTTP request log configurations
        modelBuilder.ApplyConfigurationsFromAssembly(typeof(HttpRequestLogConfiguration).Assembly);
    }
}

// Configure middleware in Program.cs
var app = builder.Build();

// Add HTTP request logging middleware (should be one of the first middleware)
app.FermatHttpRequestLogMiddleware();

// Add other middleware
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

API Endpoints

The library provides the following RESTful API endpoints when EnableApiEndpoints is set to true:

  • GET /api/http-request-logs/{id} - Get specific request log details
  • GET /api/http-request-logs/pageable - Get request logs with filtering and pagination
  • DELETE /api/http-request-logs/cleanup - Clean up old request logs
  • GET /api/http-request-logs/response-time-stats - Get response time statistics
  • GET /api/http-request-logs/slowest-endpoints - Get the slowest endpoints analysis
  • GET /api/http-request-logs/most-frequent-endpoints - Get most frequent endpoints
  • GET /api/http-request-logs/status-code-distribution - Get status code distribution
  • GET /api/http-request-logs/request-rate - Get request rate over time
  • GET /api/http-request-logs/error-rate - Get error rate over time
  • GET /api/http-request-logs/client-usage - Get client usage statistics
  • GET /api/http-request-logs/total-count - Get total log count

DTOs

HTTP Request Logs

  • HttpRequestLogResponseDto: Detailed request log information
  • GetListHttpRequestLogRequestDto: Filtering and pagination options

Performance Analysis

  • ResponseTimeStatsRequestDto: Response time statistics parameters
  • ResponseTimeStatsResponseDto: Response time statistics results
  • EndpointPerformanceResponseDto: Endpoint performance results
  • EndpointUsageResponseDto: Endpoint usage results

Rate Analysis

  • RateOverTimeRequestDto: Rate analysis parameters
  • DefaultRateOverTimeResponseDto: Request rate results
  • ErrorRateOverTimeResponseDto: Error rate results

Client Analysis

  • ClientUsageStatsResponseDto: Client usage statistics
  • DateRangeRequestDto: Date range parameters

Enums

  • TimeInterval: Time interval options (Minute, Hour, Day, Week, Month)
  • SortOrderTypes: Sorting order options (Asc, Desc)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1 115 7/28/2025