Audit.NET.MongoDB 27.4.1

Audit.NET.MongoDB

Mongo DB provider for Audit.NET library. (An extensible framework to audit executing operations in .NET).

Store the audit events in a Mongo DB Collection, in BSON format.

Install

NuGet Package

PM> Install-Package Audit.NET.MongoDB

NuGet Status NuGet Count

Usage

Please see the Audit.NET Readme

Configuration

Set the static Audit.Core.Configuration.DataProvider property to set the Mongo DB data provider, or call the UseMongoDB method on the fluent configuration. This should be done before any AuditScope creation, i.e. during application startup.

For example:

Audit.Core.Configuration.DataProvider = new Audit.MongoDB.Providers.MongoDataProvider()
{
    ConnectionString = "mongodb://localhost:27017",
    Database = "Audit",
    Collection = "Event"
};

Or by using the fluent configuration API:

Audit.Core.Configuration.Setup()
    .UseMongoDB(config => config
        .ConnectionString("mongodb://localhost:27017")
        .Database("Audit")
        .Collection("Event"));

Instead of using the connection string, you have the option to supply the MongoClientSettings instead:

Audit.Core.Configuration.Setup()
    .UseMongoDB(config => config
        .ClientSettings(new MongoClientSettings() 
        { 
            Server = new MongoServerAddress("localhost", 27017), 
            UseTls = true 
        })
        .Database("Audit")
        .Collection("Event"));

You can find more information about MongoClientSettings here.

Provider options

Mandatory:

  • ConnectionString: The Mongo DB connection string.
  • ClientSettings: The Mongo DB client settings.
  • Database: The audit Mongo Database name.
  • DatabaseSettings: The audit Mongo Database settings (optional).
  • Collection: The events Mongo Collection name.
  • SerializeAsBson: A value indicating whether the target object and extra fields should be serialized as Bson. Default is false to serialize as Json.

Output sample

An example of the output as seen with NoSQL Manager for Mongo DB:

MongoDB sample

Query events

This provider implements GetEvent and GetEventAsync methods to obtain an audit event by id:

var event = mongoDataProvider.GetEvent("57b60f25be5914a355771629");

The Mongo DB data provider also includes support for querying the events collection.

You can use the QueryEvents() method on MongoDataProvider class to run LINQ queries against the audit events.

For example, to get the top 10 most time-consuming events for a specific machine:

IQueryable<AuditEvent> query = mongoDataProvider.QueryEvents()
	.Where(ev => ev.Environment.MachineName == "HP")
	.OrderByDescending(ev => ev.Duration)
	.Take(10);

No packages depend on Audit.NET.MongoDB.

.NET Framework 4.6.2

.NET Framework 4.7.2

.NET 6.0

.NET Standard 2.0

.NET Standard 2.1

Version Downloads Last updated
27.4.1 4 02/12/2025
27.4.0 4 02/02/2025
27.3.3 5 01/27/2025
27.3.2 5 12/12/2024
27.3.1 7 12/12/2024
27.3.0 5 12/11/2024
27.2.0 6 12/01/2024
27.1.1 8 10/30/2024
27.1.0 8 10/27/2024
27.0.3 5 10/05/2024
27.0.2 11 09/19/2024
27.0.1 7 09/05/2024
27.0.0 8 09/04/2024
26.0.1 8 08/22/2024
26.0.0 8 07/23/2024
25.0.7 14 07/05/2024
25.0.6 19 06/25/2024
25.0.5 20 06/23/2024
25.0.4 16 03/29/2024
25.0.3 17 03/13/2024
25.0.2 19 03/12/2024
25.0.1 9 03/07/2024
25.0.0 11 02/20/2024
24.0.1 10 02/19/2024
24.0.0 12 02/20/2024
23.0.0 10 02/20/2024
22.1.0 7 12/15/2023
22.0.2 12 12/07/2023
22.0.1 9 12/07/2023
22.0.0 9 12/07/2023
21.1.0 8 01/07/2024
21.0.4 10 01/07/2024
21.0.3 8 12/15/2023
21.0.2 9 02/20/2024
21.0.1 10 08/28/2023
21.0.0 8 08/30/2023
20.2.4 15 08/31/2023
20.2.3 14 08/27/2023
20.2.2 11 08/27/2023
20.2.1 9 08/28/2023
20.2.0 11 08/28/2023
20.1.6 11 08/25/2023
20.1.5 16 08/27/2023
20.1.4 11 08/29/2023
20.1.3 9 08/31/2023
20.1.2 10 08/24/2023
20.1.1 12 08/29/2023
20.1.0 10 08/30/2023
20.0.4 12 08/28/2023
20.0.3 11 08/28/2023
20.0.2 10 08/30/2023
20.0.1 12 08/29/2023
20.0.0 11 08/25/2023
19.4.1 11 08/28/2023
19.4.0 12 08/27/2023
19.3.0 10 08/29/2023
19.2.2 9 08/30/2023
19.2.1 9 08/29/2023
19.2.0 11 08/30/2023
19.1.4 12 08/25/2023
19.1.3 12 08/25/2023
19.1.2 10 08/31/2023
19.1.1 9 02/20/2024
19.1.0 10 08/30/2023
19.0.7 14 08/28/2023
19.0.6 10 08/28/2023
19.0.5 9 08/27/2023
19.0.4 15 08/29/2023
19.0.3 11 08/30/2023
19.0.2 14 08/31/2023
19.0.1 11 08/28/2023
19.0.0 10 08/31/2023
19.0.0-rc.net60.2 6 08/31/2023
19.0.0-rc.net60.1 9 08/28/2023
18.1.6 9 08/30/2023
18.1.5 10 08/24/2023
18.1.4 8 10/16/2023
18.1.3 10 08/27/2023
18.1.2 10 08/31/2023
18.1.1 10 08/27/2023
18.1.0 10 08/27/2023
18.0.1 9 08/30/2023
18.0.0 10 08/28/2023
17.0.8 8 08/31/2023
17.0.7 9 08/31/2023
17.0.6 13 08/27/2023
17.0.5 11 08/28/2023
17.0.4 8 08/29/2023
17.0.3 8 09/01/2023
17.0.2 11 08/26/2023
17.0.1 9 02/19/2024
17.0.0 11 08/29/2023
16.5.6 10 08/27/2023
16.5.5 8 08/27/2023
16.5.4 8 08/28/2023
16.5.3 6 08/28/2023
16.5.2 10 08/29/2023
16.5.1 8 08/30/2023
16.5.0 6 08/30/2023
16.4.5 6 08/25/2023
16.4.4 7 08/24/2023
16.4.3 8 08/26/2023
16.4.2 9 08/27/2023
16.4.1 9 08/27/2023
16.4.0 7 08/25/2023
16.3.3 8 08/31/2023
16.3.2 6 08/28/2023
16.3.1 8 08/28/2023
16.3.0 10 08/27/2023
16.2.1 9 08/27/2023
16.2.0 10 08/31/2023
16.1.5 10 08/31/2023
16.1.4 8 08/31/2023
16.1.3 9 08/29/2023
16.1.2 8 08/31/2023
16.1.1 12 08/31/2023
16.1.0 9 08/26/2023
16.0.3 7 08/25/2023
16.0.2 14 08/31/2023
16.0.1 8 08/30/2023
16.0.0 8 08/29/2023
15.3.0 8 08/26/2023
15.2.3 10 08/26/2023
15.2.2 11 08/28/2023
15.2.1 12 12/05/2023
15.2.0 8 08/28/2023
15.1.1 13 08/26/2023
15.1.0 8 08/27/2023
15.0.5 9 08/29/2023
15.0.4 9 08/29/2023
15.0.3 7 02/20/2024
15.0.2 7 02/20/2024
15.0.1 8 08/25/2023
15.0.0 10 08/26/2023
14.9.1 10 08/24/2023
14.9.0 10 08/28/2023
14.8.1 11 08/28/2023
14.8.0 12 08/28/2023
14.7.0 8 08/31/2023
14.6.6 8 08/28/2023
14.6.5 9 08/30/2023
14.6.4 8 09/01/2023
14.6.3 8 02/20/2024
14.6.2 11 08/26/2023
14.6.1 9 08/25/2023
14.6.0 11 08/31/2023
14.5.7 11 08/29/2023
14.5.6 10 08/29/2023
14.5.5 10 08/30/2023
14.5.4 12 08/30/2023
14.5.3 10 08/29/2023
14.5.2 9 08/31/2023
14.5.1 8 02/19/2024
14.5.0 8 02/20/2024
14.4.0 11 08/28/2023
14.3.4 8 08/28/2023
14.3.3 8 02/20/2024
14.3.2 12 08/24/2023
14.3.1 9 08/31/2023
14.3.0 10 08/27/2023
14.2.3 10 09/01/2023
14.2.2 8 08/27/2023
14.2.1 8 08/28/2023
14.2.0 47 11/29/2019
14.1.1 9 08/24/2023
14.1.0 9 08/28/2023
14.0.4 9 08/30/2023
14.0.3 10 08/29/2023
14.0.2 9 08/28/2023
14.0.1 7 08/28/2023
14.0.0 7 08/31/2023
13.3.0 9 08/25/2023
13.2.2 9 08/24/2023
13.2.1 11 08/29/2023
13.2.0 9 08/24/2023
13.1.5 15 08/31/2023
13.1.4 10 08/29/2023
13.1.3 8 08/30/2023
13.1.2 9 08/31/2023
13.1.1 7 02/19/2024
13.1.0 9 08/24/2023
13.0.0 10 08/30/2023
12.3.6 8 08/25/2023
12.3.5 10 08/29/2023
12.3.4 8 08/29/2023
12.3.3 11 08/31/2023
12.3.2 8 08/31/2023
12.3.1 11 08/28/2023
12.3.0 7 08/30/2023
12.2.2 9 08/27/2023
12.2.1 11 08/29/2023
12.2.0 10 08/27/2023
12.1.11 9 08/30/2023
12.1.10 9 08/28/2023
12.1.9 9 08/29/2023
12.1.8 8 08/29/2023
12.1.7 10 08/30/2023
12.1.6 10 08/31/2023
12.1.5 11 08/31/2023
12.1.4 9 08/25/2023
12.1.3 12 08/31/2023
12.1.2 13 08/29/2023
12.1.1 13 09/01/2023
12.1.0 11 08/25/2023
12.0.7 9 08/26/2023
12.0.6 12 12/05/2023
12.0.5 10 08/29/2023
12.0.4 8 09/01/2023
12.0.3 13 08/25/2023
12.0.2 10 08/25/2023
12.0.1 10 08/27/2023
12.0.0 7 08/27/2023
11.2.0 7 02/20/2024
11.1.0 9 08/30/2023
11.0.8 8 08/25/2023
11.0.7 9 08/29/2023
11.0.6 8 08/31/2023
11.0.5 9 02/20/2024
11.0.4 8 12/05/2023
11.0.3 7 08/25/2023
11.0.2 11 08/30/2023
11.0.1 9 08/25/2023
11.0.0 11 08/30/2023
10.0.3 9 08/25/2023
10.0.2 7 08/30/2023
10.0.1 12 08/29/2023
10.0.0 13 08/27/2023
9.3.0 10 12/30/2023
9.2.0 8 02/20/2024
9.1.3 11 06/13/2023
9.1.2 15 06/13/2023
9.1.1 13 06/13/2023
9.1.0 12 06/13/2023
9.0.1 10 02/20/2024
9.0.0 12 06/12/2023
8.7.0 12 06/13/2023
8.6.0 12 06/12/2023
8.5.0 9 02/19/2024
8.4.0 12 06/14/2023
8.3.1 9 06/13/2023
8.3.0 9 06/12/2023
8.2.0 9 06/13/2023
8.1.0 9 01/26/2024
8.0.0 11 02/19/2024
7.1.3 10 02/20/2024
7.1.2 10 06/14/2023
7.1.1 9 06/12/2023
7.1.0 8 06/13/2023
7.0.9 15 06/13/2023
7.0.8 9 02/20/2024
7.0.6 12 06/13/2023
7.0.5 9 02/20/2024
7.0.4 11 06/13/2023
7.0.3 10 06/13/2023
7.0.2 8 02/19/2024
7.0.0 11 06/13/2023
6.2.0 11 12/30/2023
6.1.0 11 06/13/2023
6.0.0 10 06/13/2023
5.3.0 11 06/13/2023
5.2.0 11 06/13/2023
5.1.0 9 02/20/2024
5.0.0 10 06/14/2023
4.11.0 10 02/20/2024
4.10.0 8 08/28/2023
4.9.0 10 06/13/2023
4.8.0 9 06/13/2023
4.7.0 11 06/13/2023
4.6.5 11 06/14/2023
4.6.4 13 06/13/2023
4.6.2 11 06/13/2023
4.6.1 9 02/20/2024
4.6.0 10 02/20/2024
4.5.9 9 06/13/2023
4.5.8 9 06/13/2023
4.5.7 10 06/13/2023
4.5.6 10 06/13/2023
4.5.5 7 02/20/2024
4.5.4 9 06/13/2023
4.5.3 13 06/13/2023
4.5.2 11 06/13/2023
4.5.1 10 02/20/2024
4.5.0 8 06/14/2023
4.4.0 8 06/13/2023
4.3.0 6 12/05/2023
4.2.0 8 02/20/2024
4.1.0 8 06/14/2023
4.0.1 10 06/13/2023
4.0.0 8 06/14/2023
3.6.0 10 06/14/2023
3.4.0 9 06/13/2023
3.3.0 7 06/14/2023
3.2.0 9 06/14/2023
3.1.0 7 06/14/2023
3.0.1 8 02/20/2024
3.0.0 8 02/20/2024
2.6.0 7 06/13/2023
2.5.0 13 06/13/2023
2.4.0 7 06/14/2023
2.3.0 12 06/13/2023
2.1.0 11 06/14/2023
2.0.0 10 06/13/2023
1.0.0.4 8 09/22/2023
1.0.0.3 8 02/20/2024
1.0.0.1 12 02/19/2024
1.0.0 7 02/19/2024