Levge.AuditLog 1.0.19

There is a newer version of this package available.
See the version list below for details.
dotnet add package Levge.AuditLog --version 1.0.19
                    
NuGet\Install-Package Levge.AuditLog -Version 1.0.19
                    
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="Levge.AuditLog" Version="1.0.19" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Levge.AuditLog" Version="1.0.19" />
                    
Directory.Packages.props
<PackageReference Include="Levge.AuditLog" />
                    
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 Levge.AuditLog --version 1.0.19
                    
#r "nuget: Levge.AuditLog, 1.0.19"
                    
#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 Levge.AuditLog@1.0.19
                    
#: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=Levge.AuditLog&version=1.0.19
                    
Install as a Cake Addin
#tool nuget:?package=Levge.AuditLog&version=1.0.19
                    
Install as a Cake Tool

Levge.AuditLog

NuGet Build

🇹🇷 Türkçe açıklama için tıklayın.


Levge.AuditLog is a powerful and flexible audit logging system for Entity Framework Core. It automatically tracks and logs all changes (Create, Update, Delete) to your entities, including user information, timestamps, and field-level changes. The package also supports HTTP request logging, soft delete, per-user tracking, and scheduled cleanup of old logs.

Features

  • ✅ Entity Change Tracking
    • Tracks Insert, Update, Delete operations automatically
    • Logs user ID, timestamp, and changed fields
    • Stores both old and new values (except for Added)
    • Integrates with ICurrentUser<TKey> from Levge.Identity
  • ✅ HTTP Request Logging
    • Logs incoming HTTP requests and responses
    • Captures headers, body, and response details
  • ✅ Cleanup Jobs
    • Scheduled cleanup of old audit and request logs
    • Configurable retention policies

Installation

Install the package via NuGet: Install-Package Levge.AuditLog Or via .NET CLI: dotnet add package Levge.AuditLog

Setup

  1. Configure DbContext

    Inherit your DbContext from LevgeAuditDbContext<TKey>: public class MyDbContext : LevgeAuditDbContext<int> { public MyDbContext(DbContextOptions options, ICurrentUser<int> currentUser) : base(options, currentUser) { } }

  2. Register Services

    Add the required services in your Startup.cs or Program.cs: services.AddLevgeAuditLog<MyDbContext, int>(options ⇒ { options.EnableCleanupJob = true; options.RetentionDays = 30; });

  3. Middleware for Request Logging

    Add the request logging middleware to your pipeline: app.UseMiddleware<RequestLoggingMiddleware<int>>();

  4. Enable Cleanup Jobs

    Ensure the cleanup jobs are registered and running: services.AddHostedService<AuditLogCleanupJob<MyDbContext, int>>(); services.AddHostedService<RequestLogCleanupJob<MyDbContext, int>>();

Usage

Entity Change Tracking

All changes to your entities (Insert, Update, Delete) will be automatically logged in the AuditLogs table. You can query the logs as follows: var logs = await dbContext.AuditLogs.ToListAsync();

HTTP Request Logging

Incoming HTTP requests and responses will be logged in the RequestLogs table. You can query the logs as follows: var requestLogs = await dbContext.RequestLogs.ToListAsync();

Configuration Options

AuditLogOptions

  • EnableCleanupJob: Enables or disables the cleanup job for old audit logs.
  • RetentionDays: Number of days to retain audit logs.
  • CleanupTime: Time of day to run the cleanup job.

RequestLoggingOptions

  • Enabled: Enables or disables HTTP request logging.
  • RetentionDays: Number of days to retain request logs.
  • CleanupTime: Time of day to run the cleanup job.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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.1.47 151 7/3/2025
1.1.46 146 7/3/2025
1.1.45 136 7/3/2025
1.1.44 144 7/3/2025
1.1.43 138 7/3/2025
1.1.42 141 7/2/2025
1.1.41 138 7/2/2025
1.0.20 112 6/21/2025
1.0.19 112 6/21/2025
1.0.18 109 6/21/2025
1.0.17 103 6/21/2025
1.0.16 142 6/19/2025
1.0.15 141 6/19/2025
1.0.13 143 6/19/2025
1.0.12 144 6/19/2025
1.0.11 145 6/19/2025
1.0.10 140 6/19/2025
1.0.9 139 6/19/2025
1.0.8 146 6/18/2025
1.0.7 145 6/18/2025
1.0.6 141 6/18/2025
1.0.5 147 6/18/2025
1.0.4 139 6/18/2025
1.0.3 153 6/18/2025
1.0.2 143 6/18/2025
1.0.0 150 6/17/2025