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" />
<PackageReference Include="Fermion.EntityFramework.AuditLogs" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Fermion.EntityFramework.AuditLogs&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 paginationGET /api/auditlogs/{id}
- Get specific audit log detailsGET /api/auditlogs/user-activity
- Get user activity analysisGET /api/auditlogs/user-behavior
- Get user behavior analysisGET /api/auditlogs/most-modified
- Get most modified entitiesGET /api/auditlogs/trends
- Get entity changes trendsGET /api/auditlogs/summary
- Get entity change summary
DTOs
Audit Logs
AuditLogResponseDto
: Detailed audit log informationGetListAuditLogRequestDto
: Filtering and pagination optionsUserActivityDto
: User activity metricsUserChangeBehaviorRequestDto
: User behavior analysis parametersUserChangeBehaviorResponseDto
: User behavior analysis results
Entity Property Changes
EntityPropertyChangeResponseDto
: Property change details
Analysis
MostModifiedEntitiesRequestDto
: Most modified entities parametersMostModifiedEntitiesResponseDto
: Most modified entities resultsEntityChangesTrendRequestDto
: Trend analysis parametersEntityChangesTrendResponseDto
: Trend analysis resultsEntityChangeSummaryRequestDto
: Summary analysis parametersEntityChangeSummaryResponseDto
: Summary analysis results
Enums
States
: Audit log states (Added, Modified, Deleted)TimeGrouping
: Time grouping options (Hourly, Daily, Weekly, Monthly)
Product | Versions 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.
-
net8.0
- AutoMapper.Extensions.Microsoft.DependencyInjection (>= 12.0.1)
- Fermion.EntityFramework.Shared (>= 1.0.1)
- FluentValidation.DependencyInjectionExtensions (>= 11.11.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.EntityFrameworkCore (>= 9.0.3)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.