SkillAgentSearch skills...

Audit.NET

An extensible framework to audit executing operations in .NET

Install / Use

/learn @thepirat000/Audit.NET
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Audit.NET

USAGE | OUTPUT | CUSTOMIZATION | DATA PROVIDERS | CREATION POLICY | CONFIGURATION | EXTENSIONS

Issues | Build status | Quality gate | Donations | Docs ------------ | ---------------- | ---------------- | -------------- | -------------- issues-open issues-closed | build-status | Quality Gate Status Coverage | paypal | Ask DeepWiki

An extensible framework to audit executing operations in .NET and .NET Core.

Generate audit logs with evidence for reconstruction and examination of activities that have affected specific operations or procedures.

With Audit.NET, you can generate detailed tracking information for executed operations. It captures environmental data such as the caller's user ID, machine name, method name, exceptions, and execution time. The framework also provides an extensible mechanism to enrich logs and manage audit outputs.

NuGet

NuGet Status NuGet Count

To install the package run the following command on the Package Manager Console:

PM> Install-Package Audit.NET

Changelog

Check the CHANGELOG.md file.

ZZZ Projects - Sponsorship

Entity Framework Extensions and Dapper Plus are major sponsors and are proud to contribute to the development of Audit.NET

Combine the power of auditing with the speed of Bulk Operations to get the best of both worlds — audit and performance.

Entity Framework Extensions - Sponsor

Dapper Plus - Sponsor

Introduction

The Audit Scope and Audit Event are the central objects of this framework.

Audit Scope

The AuditScope serves as the central object in this framework, representing the scope of an audited operation or event. It acts as a context for auditing, capturing pertinent details like the start time, involved entities, and any additional custom information. Essentially, the AuditScope encapsulates an AuditEvent, controlling its life cycle.

The AuditScope is a disposable object, commonly utilized within a using statement to ensure proper finalization and recording of audit information upon exiting the scope.

See the audit scope statechart.

Audit Event

The AuditEvent functions as an extensible information container that captures the details of the audited operation, is the representation of the audited information within an Audit Scope. It includes details about the audited operation, such as the event type, timestamp, execution duration, and any custom fields or properties.

The AuditEvent is typically serialized into a format suitable for storage or transmission, such as JSON.

The audit events are stored using a Data Provider. You can use one of the available data providers or implement your own.

Audit Scope Factory

The preferred method for creating audit scopes is by using an IAuditScopeFactory instance. This approach ensures a centralized and consistent configuration for all audit scopes.

var factory = new AuditScopeFactory();
using var scope = factory.Create(new AuditScopeOptions(...));
...

If you're using a DI container, you can register the IAuditScopeFactory as a service and inject it into your classes. The default implementation of IAuditScopeFactory is provided by the AuditScopeFactory class.

services.AddScoped<IAuditScopeFactory, AuditScopeFactory>();

Then you can inject the IAuditScopeFactory into your classes to create audit scopes:

public class MyService
{
  private readonly IAuditScopeFactory _auditScopeFactory;

  public MyService(IAuditScopeFactory auditScopeFactory)
  {
    _auditScopeFactory = auditScopeFactory;
  }

  public void MyMethod()
  {
    using var scope = _auditScopeFactory.Create(new AuditScopeOptions(...));
    ...
  }
}

You can also implement your own IAuditScopeFactory to customize the creation of audit scopes. The recommended approach is to inherit from the AuditScopeFactory class. By overriding the OnConfiguring and OnScopeCreated methods, you can configure the audit scope options before creation and customize the audit scope after creation respectively.

For example:

publ

Related Skills

View on GitHub
GitHub Stars2.6k
CategoryDevelopment
Updated3d ago
Forks331

Languages

C#

Security Score

100/100

Audited on Mar 25, 2026

No findings