Audit.NET.RavenDB 1.6.1

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

Audit.NET.RavenDB

Quality Gate Status Build Status Vulnerabilities Coverage CodeQL

NuGet Status NuGet Count

Overview

RavenDB storage provider for Audit.NET

Setup

Set up the Audit.NET RavenDB provider during application startup with defaults storing object diffs

Audit.Core.Configuration.Setup()
  .UseRavenDB(configuration.GetSection("RavenSettings:Urls").Get<string[]>(),
    new X509Certificate2(Path.Combine(HttpContext.Current.Server.MapPath(""), configuration["RavenSettings:CertFilePath"]), configuration["RavenSettings:CertPassword"]),
    configuration["RavenSettings:DatabaseName"]);

Alternatively, set up the Audit.NET RavenDB provider during application startup storing full objects

Audit.Core.Configuration.Setup()
  .UseRavenDB(configuration.GetSection("RavenSettings:Urls").Get<string[]>(),
    new X509Certificate2(Path.Combine(HttpContext.Current.Server.MapPath(""), configuration["RavenSettings:CertFilePath"]), configuration["RavenSettings:CertPassword"]),
    configuration["RavenSettings:DatabaseName"], null, false);

Usage

Create an audit scope around the objects you are changing. Audit.NET takes a snapshot of the referenced object as it enters the scope, and compares it with the referenced object as it leaves the using block.

Audit creation of a new application, setting a custom field called Id to the app's Id after it's created

Application? app = null;
using (var audit = await AuditScope.CreateAsync("Application:Create", () => app))
{
    app = new Application
    {
        OwnerId = userId,
        Description = model.Description,
        Id = $"Applications/{Guid.NewGuid()}",
        Name = model.Name
    };
    await session.StoreAsync(app, ct);
    await session.SaveChangesAsync(ct);
    audit.SetCustomField(nameof(app.Id), app.Id);
}

Audit updating an application

using (var audit = await AuditScope.CreateAsync("Application:Update", () => app, new { app.Id }))
{
    app.Description = model.Description;
    app.Name = model.Name;
    app.Domain = model.Domain;
    app.DefaultEnvironment = model.DefaultEnvironment;

    await session.SaveChangesAsync(ct);
}

Known Bugs

No known bugs at this time. Please submit an issue if you encounter issues

Example audit records

Change property called Description on an object

{
    "Environment": {
        "UserName": "root",
        "MachineName": "7b7c96b853-ftlkw",
        "DomainName": "7b7c96b853-ftlkw",
        "CallingMethodName": "System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start()",
        "AssemblyName": "System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bdd7798e",
        "Culture": ""
    },
    "EventType": "Application:Update",
    "Target": {
        "Type": "Application",
        "Old": {
            "Description": "My Old Description"
        },
        "New": {
            "Description": "My New Description"
        }
    },
    "StartDate": "2022-03-30T13:51:45.3090112Z",
    "EndDate": "2022-03-30T13:51:45.3305599Z",
    "Duration": 22,
    "Id": "Applications/c9fa19a0-dafa-4f77-b751-3119475d0815",
    "UserId": "ApplicationUsers/1-A",
    "@metadata": {
        "@collection": "AuditEvents",
        "Raven-Clr-Type": "Audit.Core.AuditEvent, Audit.NET"
    }
}

Remove an object from a deeply nested array

{
    "Environment": {
        "UserName": "root",
        "MachineName": "7b7c96b855-rm8bl",
        "DomainName": "7b7c96b855-rm8bl",
        "CallingMethodName": "System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start()",
        "AssemblyName": "System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bdd7798e",
        "Culture": ""
    },
    "EventType": "Application:UpdateEnvironment",
    "Target": {
        "Type": "Application",
        "Old": {
            "Environments": {
                "Production": {
                    "Definitions": {
                        "Test": [
                            {
                                "Name": "AlwaysOn",
                                "Parameters": null
                            }
                        ]
                    }
                }
            }
        },
        "New": {
            "Environments": {
                "Production": {
                    "Definitions": {
                        "Test": []
                    }
                }
            }
        }
    },
    "StartDate": "2022-03-30T13:52:18.1276474Z",
    "EndDate": "2022-03-30T13:52:18.3096561Z",
    "Duration": 182,
    "Id": "Applications/c91119ad-aaaa-2277-b751-311aaaad0815",
    "UserId": "ApplicationUsers/1232-C",
    "@metadata": {
        "@collection": "AuditEvents",
        "Raven-Clr-Type": "Audit.Core.AuditEvent, Audit.NET"
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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
31.3.1 44 12/9/2025
31.3.0 146 12/5/2025
31.2.0 169 11/27/2025
31.1.0 175 11/26/2025
31.0.2 288 10/2/2025
31.0.1 263 8/28/2025
31.0.0 184 8/22/2025
30.1.3 197 8/19/2025
30.1.2 202 8/14/2025
30.1.1 205 8/13/2025
30.0.2 211 6/26/2025
30.0.1 229 5/29/2025
30.0.0 202 5/27/2025
29.0.1 220 5/8/2025
29.0.0 227 5/6/2025
28.0.0 217 5/5/2025
27.5.3 254 4/23/2025
27.5.2 253 4/9/2025
27.5.1 171 4/4/2025
27.5.0 502 3/5/2025
27.4.1 210 2/9/2025
27.4.0 178 1/29/2025
27.3.3 272 1/21/2025
27.3.2 193 12/11/2024
27.3.1 193 12/10/2024
27.3.0 199 12/8/2024
27.2.0 189 11/23/2024
27.1.1 191 10/28/2024
27.1.0 204 10/24/2024
27.0.3 324 9/25/2024
27.0.2 207 9/19/2024
27.0.1 459 9/4/2024
27.0.0 201 9/3/2024
26.0.1 845 8/22/2024
26.0.0 558 7/19/2024
25.0.7 322 7/4/2024
25.0.6 201 6/24/2024
25.0.5 215 6/18/2024
25.0.4 385 3/24/2024
25.0.3 267 3/13/2024
25.0.2 212 3/12/2024
25.0.1 208 2/28/2024
25.0.0 237 2/16/2024
24.0.1 232 2/12/2024
24.0.0 218 2/12/2024
23.0.0 372 12/14/2023
22.1.0 1,865 12/9/2023
22.0.2 2,650 12/1/2023
22.0.1 200 11/16/2023
22.0.0 169 11/14/2023
21.1.0 1,435 10/9/2023
21.0.4 246 9/15/2023
21.0.3 270 7/9/2023
21.0.2 247 7/6/2023
21.0.1 620 5/27/2023
21.0.0 510 4/15/2023
20.2.4 345 3/27/2023
20.2.3 372 3/17/2023
20.2.2 338 3/14/2023
20.2.1 945 3/11/2023
20.2.0 322 3/7/2023
20.1.6 360 2/23/2023
20.1.5 377 2/9/2023
20.1.4 607 1/28/2023
20.1.3 474 12/21/2022
20.1.2 427 12/14/2022
20.1.1 425 12/12/2022
20.1.0 455 12/4/2022
20.0.4 445 11/30/2022
20.0.3 782 10/28/2022
20.0.2 537 10/26/2022
20.0.1 584 10/21/2022
20.0.0 670 10/1/2022
19.4.1 669 9/10/2022
19.4.0 611 9/2/2022
19.3.0 607 8/23/2022
19.2.2 607 8/11/2022
19.2.1 622 8/6/2022
19.2.0 706 7/24/2022
19.1.4 1,180 5/23/2022
19.1.3 605 5/22/2022
19.1.2 620 5/18/2022
19.1.1 930 4/28/2022
19.1.0 1,145 4/10/2022
1.6.3 934 4/6/2022
1.6.2 2,594 3/30/2022
1.6.1 609 3/30/2022
1.6.0 609 3/30/2022
1.5.0 886 2/8/2022
1.4.1 874 2/8/2022
1.4.0 620 2/7/2022
1.3.2 649 2/1/2022
1.3.1 655 1/31/2022
1.3.0 621 1/31/2022
1.2.2 614 1/31/2022
1.2.1 602 1/31/2022
1.2.0 625 1/31/2022
1.1.0 620 1/31/2022
1.0.0 1,469 1/4/2021