Appearance
GrydAudit Module
GrydAudit is a comprehensive audit logging module for Gryd.IO applications. It provides automatic tracking of entity changes, user actions, and security events following the 5W1H principle (Who, What, When, Where, Why, How).
Features
- Automatic Entity Tracking: Intercepts EF Core SaveChanges to capture all entity modifications
- 5W1H Audit Principle: Captures complete context for each audit event
- Builder Pattern: Fluent API for creating audit entries
- CQRS Support: MediatR-based queries for retrieving audit logs
- REST API: Ready-to-use endpoints for audit log access
- Multi-tenant Ready: Full tenant isolation support
- LGPD/GDPR Compliant: Sensitive data exclusion and compliance verification
Architecture
GrydAudit/
├── GrydAudit.Core/ # Domain entities and abstractions
├── GrydAudit.Application/ # CQRS handlers
├── GrydAudit.Infrastructure/ # EF Core implementation
├── GrydAudit.API/ # REST controllers
└── GrydAudit/ # Meta-packageQuick Start
1. Install the package
bash
dotnet add package GrydAudit2. Configure services
csharp
services.AddGrydAudit(connectionString);3. Mark entities as auditable
csharp
public class Product : IAuditableEntity
{
public Guid Id { get; set; }
public string Name { get; set; }
// ... other properties
}See Getting Started for detailed setup instructions.
Packages
| Package | Description |
|---|---|
GrydAudit.Core | Domain entities, abstractions, and DTOs |
GrydAudit.Application | MediatR queries and handlers |
GrydAudit.Infrastructure | EF Core DbContext, interceptors, and repository |
GrydAudit.API | REST API controllers |
GrydAudit | Meta-package including all above |
Core Concepts
AuditLog Entity
The central entity that stores audit information:
- Who: UserId, UserName, IpAddress, UserAgent
- What: EntityType, EntityId, Action (Created/Updated/Deleted)
- When: Timestamp (UTC)
- Where: TenantId, ServiceName
- Why: Reason (optional business justification)
- How: PropertyChanges (old/new values)
Audit Actions
| Action | Description |
|---|---|
Created | Entity was inserted |
Updated | Entity was modified |
Deleted | Entity was removed |
Accessed | Entity was read (optional) |
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/auditlogs/{id} | Get audit log by ID |
| GET | /api/auditlogs/entity/{entityType}/{entityId} | Get entity history |
| GET | /api/auditlogs/user/{userId} | Get user's audit logs |
| GET | /api/auditlogs/search | Search with filters |