Fermion.EntityFramework.AuditLogs 1.0.1

dotnet add package Fermion.EntityFramework.AuditLogs --version 1.0.1
                    
NuGet\Install-Package Fermion.EntityFramework.AuditLogs -Version 1.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="Fermion.EntityFramework.AuditLogs" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fermion.EntityFramework.AuditLogs" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Fermion.EntityFramework.AuditLogs" />
                    
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 Fermion.EntityFramework.AuditLogs --version 1.0.1
                    
#r "nuget: Fermion.EntityFramework.AuditLogs, 1.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 Fermion.EntityFramework.AuditLogs@1.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=Fermion.EntityFramework.AuditLogs&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Fermion.EntityFramework.AuditLogs&version=1.0.1
                    
Install as a Cake Tool

Fermion.EntityFramework.AuditLogs

Fermion.EntityFramework.AuditLogs is a comprehensive audit logging library for .NET applications that provides detailed tracking of entity changes, user activities, and audit trail analysis. It's built on top of Entity Framework Core and follows clean architecture principles.

Features

  • Entity change tracking with detailed property changes
  • User activity monitoring and analysis
  • Comprehensive audit trail analysis
  • Time series data analysis
  • User behavior analysis
  • Entity change summaries
  • Most modified entities tracking
  • Entity changes trend analysis
  • Clean Architecture implementation
  • RESTful API endpoints for audit log management
  • Configurable sensitive data masking
  • Flexible entity and property filtering

Installation

  dotnet add package Fermion.EntityFramework.AuditLogs

Project Structure

The library follows Clean Architecture principles with the following layers:

Core

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

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

Extensions

  • Helper methods
  • Utility functions

Configuration

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

    // Configure sensitive data masking
    opt.MaskPattern = "***MASKED***";
    opt.SensitiveProperties = [
        "Password", "Token", "Secret", "ApiKey", 
        "Key", "Credential", "Ssn", "Credit", 
        "Card", "SecurityCode", "Pin", "Authorization"
    ];

    // Configure entity-specific exclusions
    opt.ExcludedPropertiesByEntityType = new Dictionary<Type, HashSet<string>>
    {
        { typeof(Todo), ["AssignedTo"] }
    };

    // Configure entity type filtering
    opt.IncludedEntityTypes = [ 
        //typeof(Todo) 
    ];
    opt.ExcludedEntityTypes = [ 
        //typeof(Todo) 
    ];

    // Configure logging behavior
    opt.LogChangeDetails = true;
    opt.MaxValueLength = 5000;
    opt.LoggedStates = [
        States.Added,
        States.Modified,
        States.Deleted
    ];
});

// Register DbContext with audit logging
services.AddDbContext<MyDbContext>(options =>
    options.UseSqlServer(connectionString)
           .UseAuditLog()
    );


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

API Endpoints

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

  • GET /api/auditlogs - Get audit logs with filtering and pagination
  • GET /api/auditlogs/{id} - Get specific audit log details
  • GET /api/auditlogs/user-activity - Get user activity analysis
  • GET /api/auditlogs/user-behavior - Get user behavior analysis
  • GET /api/auditlogs/most-modified - Get most modified entities
  • GET /api/auditlogs/trends - Get entity changes trends
  • GET /api/auditlogs/summary - Get entity change summary

DTOs

Audit Logs

  • AuditLogResponseDto: Detailed audit log information
  • GetListAuditLogRequestDto: Filtering and pagination options
  • UserActivityDto: User activity metrics
  • UserChangeBehaviorRequestDto: User behavior analysis parameters
  • UserChangeBehaviorResponseDto: User behavior analysis results

Entity Property Changes

  • EntityPropertyChangeResponseDto: Property change details

Analysis

  • MostModifiedEntitiesRequestDto: Most modified entities parameters
  • MostModifiedEntitiesResponseDto: Most modified entities results
  • EntityChangesTrendRequestDto: Trend analysis parameters
  • EntityChangesTrendResponseDto: Trend analysis results
  • EntityChangeSummaryRequestDto: Summary analysis parameters
  • EntityChangeSummaryResponseDto: Summary analysis results

Enums

  • States: Audit log states (Added, Modified, Deleted)
  • TimeGrouping: Time grouping options (Hourly, Daily, Weekly, Monthly)
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
1.0.1 130 7/14/2025
1.0.0 137 6/29/2025