This document describes the Audit.NET extensions that integrate with application-level frameworks and infrastructure components. These extensions enable auditing of:
For auditing web requests and API endpoints, see Web Framework Integration. For auditing database operations, see Entity Framework Integration. For auditing service calls and communication protocols, see Service and Communication Integration.
The application integration extensions provide auditing capabilities for infrastructure concerns that are typically cross-cutting in nature. Unlike the data access or communication integrations, these extensions focus on application behavior patterns such as message handling, scheduled jobs, and system monitoring.
Sources: README.md15-28 CHANGELOG.md11-30
| Extension | Package | Purpose | Interception Point | Async Support | DI Integration |
|---|---|---|---|---|---|
| MediatR | Audit.MediatR | Audit CQRS commands/queries | Pipeline behavior | ✓ | ✓ |
| Hangfire | Audit.Hangfire | Audit background jobs | Client/Server filters | ✓ | ✓ |
| Azure Functions | Audit.AzureFunctions | Audit function executions | Middleware | ✓ | ✓ |
| Dynamic Proxy | Audit.DynamicProxy | Audit method calls | Castle interceptor | ✓ | ✗ |
| File System | Audit.FileSystem | Monitor file changes | FileSystemWatcher | ✓ | ✗ |
Sources: README.md15-28 Audit.NET.sln193-204
The application integration packages are organized under the src/ directory:
Sources: Audit.NET.sln193-204 Audit.NET.sln41-58 test/Run-Tests.ps131-60
All application integrations follow a consistent pattern for creating and managing audit scopes:
Sources: README.md84-102 CHANGELOG.md136-147
The Audit.MediatR package provides auditing for MediatR requests through a pipeline behavior implementation.
Key Classes:
AuditPipelineBehavior<TRequest, TResponse> - Pipeline behavior that wraps MediatR request handlingEvent Structure:
EventType: "MediatR:Request" or "MediatR:Stream"Request: Serialized request objectResponse: Serialized response object (for requests)Exception: Captured exception if thrownSources: README.md25 CHANGELOG.md20-21 Audit.NET.sln193-196
The Audit.Hangfire package audits background jobs using Hangfire's client and server filters.
Key Classes:
AuditClientFilter - Captures job creation and state changesAuditServerFilter - Captures job executionEvent Structure:
EventType: "Hangfire:JobCreated", "Hangfire:JobPerforming", or "Hangfire:JobPerformed"JobId: Hangfire job identifierJob: Job method and parametersState: Job state informationSources: README.md26 CHANGELOG.md18-19 Audit.NET.sln197-200
The Audit.AzureFunctions package provides middleware for auditing Azure Functions in the isolated worker model.
Key Classes:
AuditMiddleware - Function invocation middlewareFunctionInvocationContext - Captured invocation contextEvent Structure:
EventType: "AzureFunction:Invocation"FunctionName: Name of the invoked functionInvocationId: Unique invocation identifierTriggerType: Function trigger typeSources: README.md27 CHANGELOG.md15-16 Audit.NET.sln201-204
The Audit.DynamicProxy package uses Castle DynamicProxy to intercept method calls on any class.
Key Classes:
AuditInterceptor - Castle DynamicProxy interceptorAuditProxy - Factory for creating audited proxiesEvent Structure:
EventType: "ClassName:MethodName"Arguments: Method parametersResult: Method return valueException: Captured exception if thrownSources: README.md20 Audit.NET.sln41-44
The Audit.FileSystem package monitors and audits file system changes using FileSystemWatcher.
Key Classes:
FileSystemEventLog - Main monitoring componentFileSystemEvent - Specialized audit event for file operationsEvent Structure:
EventType: "FileCreated", "FileChanged", "FileDeleted", or "FileRenamed"Path: File pathOldPath: Previous path (for renames)Attributes: File attributesLength: File sizeMD5: Optional file content hashSources: README.md20 Audit.NET.sln57-58
The newer integrations (MediatR, Hangfire, Azure Functions) support dependency injection for the IAuditScopeFactory and AuditDataProvider:
Supported Extensions:
Audit.MediatR: Resolves IAuditScopeFactory from service providerAudit.Hangfire: Resolves both factory and providerAudit.AzureFunctions: Resolves both factory and providerNot DI-Enabled:
Audit.DynamicProxy: Uses direct instantiationAudit.FileSystem: Uses static configurationSources: CHANGELOG.md136-147 README.md172
All application integration packages are built and packaged together as part of the monorepo:
Sources: src/pack.cmd100-102 src/pack.cmd75-80 src/push.cmd94-96 src/push.cmd69-73
Each integration has dedicated unit tests that run as part of the CI/CD pipeline:
| Test Project | Category | Execution |
|---|---|---|
Audit.MediatR.UnitTest | Parallel | Multiple test runners |
Audit.Hangfire.UnitTest | Parallel | Multiple test runners |
Audit.AzureFunctions.UnitTest | Parallel | Multiple test runners |
Audit.DynamicProxy.UnitTest | Parallel | Multiple test runners |
Audit.FileSystem.UnitTest | Parallel | Multiple test runners |
Tests are executed in parallel to optimize CI/CD pipeline performance. The test framework uses NUnit with Coverlet for code coverage reporting.
Sources: test/Run-Tests.ps11-86 test/_execDotnetTest.ps11-50 Directory.Build.targets9-21
All application integration packages share the same version number, which is centrally managed:
Version Configuration:
32.0.0This versioning strategy ensures compatibility across all Audit.NET packages and simplifies dependency management.
Sources: Directory.Build.props1-7
For detailed information about each integration, refer to the following pages:
Refresh this wiki