Audit.NET.Redis 30.0.0

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

Audit.NET.Redis

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

Store the audit events in a Redis database as Strings, List, SortedSet, Hash, publish to a PubSub channel or add to a Redis Stream.

Install

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

PM> Install-Package Audit.NET.Redis

NuGet Status NuGet Count

Usage

Please see the Audit.NET Readme

Configuration

To set the Redis data provider globally, use the fluent configuration API, for example:

Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString(RedisCnnString)
        .AsString(str => str
            .Key(ev => $"{Guid.NewGuid()}")));

If you need to set different providers/configuration per scope, you can use the RedisDataProviderHelper to easily get a new Redis Data Provider via the fluent API, for example:

    var dp = new RedisDataProviderHelper(RedisCnnString)
        .AsString(str => str
            .Key(ev => $"{Guid.NewGuid()}"));

    using (AuditScope.Create(new AuditScopeOptions() { DataProvider = dp }))
    {
       // ...
    }

Common settings

  • ConnectionString indicates the redis connection string, based on StackExchange.Redis configuration.
  • ConfigurationOptions indicates the redis connection configuration options, when you need to provide custom connection options. Alternative to ConnectionString.
  • Serializer indicates a custom serialization method for the audit events. By default the events are serialized as JSON encoded as UTF-8.

Modes

This data provider allows to store the events in different ways.

Redis String

Store each audit event as a redis string.

Setup sample:

// Store audits as strings.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString("localhost:6379,allowAdmin=true")
        .AsString(str => str
            .Key(ev => $"{ev.EventType}:{Guid.NewGuid()}")));

Mandatory settings

  • Use the Key method to indicate the redis key where the event will be stored, this key can depend on the AuditEvent object.

Optional settings

  • TimeToLive specifies the Time To Live for the Redis Key. Default is no TTL.
  • Database specifies the database ID to use. Default is database 0.
  • AttachTask attaches an additional redis command to the execution.

Redis Stream

Adds each audit event to a Redis Stream.

Setup sample:

// Store audits as strings.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString("localhost")
        .AsStream(stream => stream
            .Key("MyAuditStream")
            .MaxLength(5000)
            .WithCustomField("Date", ev => DateTime.UtcNow.ToString())));

Mandatory settings

  • Use the Key method to indicate the stream redis key, this key can depend on the AuditEvent object.

Optional settings

  • Database specifies the database ID to use. Default is database 0.
  • AttachTask attaches an additional redis command to the execution.
  • MaxLength specifies the maximum quantity of events that the stream will store. Older elements will be deleted. Default is NULL for no-limit.
  • DefaultAuditEventFieldName specifies the default field name that will contain the AuditEvent JSON representation in the stream entry. Default is "AuditEvent".
  • WithCustomField allows specifying custom fields to be stored in the stream entry. By default, only the field named "AuditEvent" is stored, containing the JSON representation of the Audit Event.

Redis Hash

Store each audit event as a field in a redis hash.

Setup sample:

// Store audits in hashes per each EventType.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString(RedisCnnString)
        .AsHash(hash => hash
            .Key(ev => $"{ev.EventType}")
            .HashField(ev => $"{Guid.NewGuid()}")));

Mandatory settings:

  • Key to indicate the redis key where the hash will be stored, this key can depend on the AuditEvent object.
  • HashField to indicate the redis field inside the hash where the event will be stored.

Optional settings

  • TimeToLive specifies the Time To Live for the Redis Hash. Default is no TTL.
  • Database specifies the database ID to use. Default is database 0.
  • AttachTask attaches an additional redis command to the execution.

Redis List

Store each audit event as a member in a redis list.

Setup sample:

// Store audits in lists per each EventType, with a maximum of 1000 events per list.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString(RedisCnnString)
        .AsList(list => list
            .Key(ev => $"{ev.EventType}")
            .MaxLength(1000)));

Mandatory settings:

  • Key to indicate the redis key where the list will be stored, this key can depend on the AuditEvent object.

Optional settings:

  • MaxLength to indicate the maximum quantity of events that the list will store. Older elements will be deleted. Default is no-limit.
  • TimeToLive specifies the Time To Live for the Redis List. Default is no TTL.
  • Database specifies the database ID to use. Default is database 0.
  • AttachTask attaches an additional redis command to the execution.

Redis Sorted Set

Store each audit event as a member in a redis sorted set.

Setup sample:

// Store audits in sorted sets per each EventType, maintaining only the events from the last 30 days.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString(RedisCnnString)
        .AsSortedSet(sset => sset
            .Key(ev => $"{ev.EventType}")
            .Score(ev => ev.StartDate.Ticks)
            .MinScore(ev => DateTime.UtcNow.AddDays(-30).Ticks)));

Mandatory settings:

  • Key to indicate the redis key where the sorted set will be stored, this key can depend on the AuditEvent object.
  • Score to indicate the score as a double that the event will have, can depend on the AuditEvent object.

Optional settings:

  • MinScore specifies a function that returns the minimum score allowed for the sorted set. Audits with score less than the minimum will be deleted. This deletion takes place when a new event is stored.
  • MaxScore specifies a function that returns the maximum score allowed for the sorted set.
  • MaxRank specifies a function that returns the maximum rank allowed for the sorted set. Max>0: Maintain only the top N scored elements. Max<0: Maintain only the bottom N scored elements.
  • TimeToLive specifies the Time To Live for the Redis Sorted Set. Default is no TTL.
  • Database specifies the database ID to use. Default is database 0.
  • AttachTask attaches an additional redis command to the execution.

Redis PubSub

Sends the audit events to a redis PubSub channel.

Setup sample:

// Send audits to PubSub channels.
Audit.Core.Configuration.Setup()
    .UseRedis(redis => redis
        .ConnectionString(RedisCnnString)
        .AsPubSub(pub => pub
            .Channel(ev => $"audits:{ev.EventType}")));

Mandatory settings:

  • Channel to indicate the channel name to use for publishing the events.

Query events

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

var event = Configuration.DataProvider.GetEvent("eventId");

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

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
30.0.1 138 5/29/2025
30.0.0 137 5/27/2025
29.0.1 149 5/8/2025
29.0.0 136 5/6/2025
28.0.0 148 5/5/2025
27.5.3 165 4/23/2025
27.5.2 208 4/9/2025
27.5.1 95 4/4/2025
27.5.0 240 3/5/2025
27.4.1 118 2/9/2025
27.4.0 107 1/29/2025
27.3.3 104 1/21/2025
27.3.2 119 12/11/2024
27.3.1 105 12/10/2024
27.3.0 112 12/8/2024
27.2.0 112 11/23/2024
27.1.1 114 10/28/2024
27.1.0 104 10/24/2024
27.0.3 11,509 9/25/2024
27.0.2 119 9/19/2024
27.0.1 137 9/4/2024
27.0.0 125 9/3/2024
26.0.1 248 8/22/2024
26.0.0 115 7/19/2024
25.0.7 135 7/4/2024
25.0.6 124 6/24/2024
25.0.5 138 6/18/2024
25.0.4 2,561 3/24/2024
25.0.3 152 3/13/2024
25.0.2 142 3/12/2024
25.0.1 145 2/28/2024
25.0.0 1,063 2/16/2024
24.0.1 157 2/12/2024
24.0.0 136 2/12/2024
23.0.0 1,099 12/14/2023
22.1.0 142 12/9/2023
22.0.2 163 12/1/2023
22.0.1 1,288 11/16/2023
22.0.0 245 11/14/2023
21.1.0 190 10/9/2023
21.0.4 2,051 9/15/2023
21.0.3 606 7/9/2023
21.0.2 183 7/6/2023
21.0.1 190 5/27/2023
21.0.0 255 4/15/2023
20.2.4 288 3/27/2023
20.2.3 283 3/17/2023
20.2.2 293 3/14/2023
20.2.1 293 3/11/2023
20.2.0 274 3/7/2023
20.1.6 316 2/23/2023
20.1.5 333 2/9/2023
20.1.4 4,408 1/28/2023
20.1.3 384 12/21/2022
20.1.2 365 12/14/2022
20.1.1 353 12/12/2022
20.1.0 396 12/4/2022
20.0.4 402 11/30/2022
20.0.3 2,584 10/28/2022
20.0.2 483 10/26/2022
20.0.1 521 10/21/2022
20.0.0 1,639 10/1/2022
19.4.1 1,220 9/10/2022
19.4.0 536 9/2/2022
19.3.0 522 8/23/2022
19.2.2 2,128 8/11/2022
19.2.1 544 8/6/2022
19.2.0 1,458 7/24/2022
19.1.4 3,423 5/23/2022
19.1.3 531 5/22/2022
19.1.2 526 5/18/2022
19.1.1 903 4/28/2022
19.1.0 641 4/10/2022
19.0.7 3,597 3/13/2022
19.0.6 622 3/7/2022
19.0.5 1,050 1/28/2022
19.0.4 604 1/23/2022
19.0.3 3,503 12/14/2021
19.0.2 447 12/11/2021
19.0.1 889 11/20/2021
19.0.0 480 11/11/2021
19.0.0-rc.net60.2 208 9/26/2021
19.0.0-rc.net60.1 253 9/16/2021
18.1.6 832 9/26/2021
18.1.5 574 9/7/2021
18.1.4 499 9/6/2021
18.1.3 562 8/19/2021
18.1.2 592 8/8/2021
18.1.1 539 8/5/2021
18.1.0 542 8/1/2021
18.0.1 577 7/30/2021
18.0.0 576 7/26/2021
17.0.8 585 7/7/2021
17.0.7 553 6/16/2021
17.0.6 547 6/5/2021
17.0.5 541 5/28/2021
17.0.4 533 5/4/2021
17.0.3 505 5/1/2021
17.0.2 549 4/22/2021
17.0.1 512 4/18/2021
17.0.0 568 3/26/2021
16.5.6 536 3/25/2021
16.5.5 514 3/23/2021
16.5.4 553 3/9/2021
16.5.3 505 2/26/2021
16.5.2 531 2/23/2021
16.5.1 548 2/21/2021
16.5.0 561 2/17/2021
16.4.5 544 2/15/2021
16.4.4 526 2/5/2021
16.4.3 540 1/27/2021
16.4.2 570 1/22/2021
16.4.1 587 1/21/2021
16.4.0 562 1/11/2021
16.3.3 627 1/8/2021
16.3.2 584 1/3/2021
16.3.1 606 12/31/2020
16.3.0 572 12/30/2020
16.2.1 544 12/27/2020
16.2.0 586 10/13/2020
16.1.5 598 10/4/2020
16.1.4 632 9/17/2020
16.1.3 744 9/13/2020
16.1.2 643 9/9/2020
16.1.1 645 9/3/2020
16.1.0 631 8/19/2020
16.0.3 681 8/15/2020
16.0.2 684 8/9/2020
16.0.1 692 8/8/2020
16.0.0 628 8/7/2020
15.3.0 741 7/23/2020
15.2.3 642 7/14/2020
15.2.2 667 5/19/2020
15.2.1 666 5/12/2020
15.2.0 698 5/9/2020
15.1.1 695 5/4/2020
15.1.0 714 4/13/2020
15.0.5 685 3/18/2020
15.0.4 707 2/28/2020
15.0.3 678 2/26/2020
15.0.2 758 1/20/2020
15.0.1 717 1/10/2020
15.0.0 727 12/17/2019
14.9.1 722 11/30/2019
14.9.0 707 11/29/2019
14.8.1 730 11/26/2019
14.8.0 767 11/20/2019
14.7.0 726 10/9/2019
14.6.6 712 10/8/2019
14.6.5 719 9/27/2019
14.6.4 728 9/21/2019
14.6.3 754 8/12/2019
14.6.2 782 8/3/2019
14.6.1 775 8/3/2019
14.6.0 747 7/26/2019
14.5.7 751 7/18/2019
14.5.6 785 7/10/2019
14.5.5 743 7/1/2019
14.5.4 750 6/17/2019
14.5.3 785 6/5/2019
14.5.2 797 5/30/2019
14.5.1 769 5/28/2019
14.5.0 824 5/24/2019
14.4.0 804 5/22/2019
14.3.4 762 5/14/2019
14.3.3 777 5/9/2019
14.3.2 795 4/30/2019
14.3.1 791 4/27/2019
14.3.0 863 4/24/2019
14.2.3 791 4/17/2019
14.2.2 789 4/10/2019
14.2.1 773 4/5/2019
14.2.0 795 3/16/2019
14.1.1 814 3/8/2019
14.1.0 876 2/11/2019
14.0.4 895 1/31/2019
14.0.3 920 1/22/2019
14.0.2 942 12/15/2018
14.0.1 931 11/29/2018
14.0.0 979 11/19/2018
13.3.0 957 11/16/2018
13.2.2 959 11/15/2018
13.2.1 1,000 11/13/2018
13.2.0 992 10/31/2018
13.1.5 971 10/31/2018
13.1.4 975 10/25/2018
13.1.3 960 10/18/2018
13.1.2 1,075 9/12/2018
13.1.1 1,024 9/11/2018
13.1.0 1,021 9/11/2018
13.0.0 1,172 8/29/2018
12.3.6 1,084 8/29/2018
12.3.5 1,093 8/22/2018
12.3.4 1,074 8/21/2018
12.3.3 25,811 8/21/2018
12.3.2 1,086 8/20/2018
12.3.1 1,114 8/20/2018
12.3.0 1,111 8/20/2018
12.2.2 1,147 8/15/2018
12.2.1 1,141 8/9/2018
12.2.0 1,149 8/8/2018
12.1.11 1,138 7/30/2018
12.1.10 1,165 7/20/2018
12.1.9 1,317 7/10/2018
12.1.8 1,158 7/2/2018
12.1.7 1,306 6/7/2018
12.1.6 1,170 6/4/2018
12.1.5 1,293 6/2/2018
12.1.4 1,141 5/25/2018
12.1.3 1,417 5/16/2018
12.1.2 1,196 5/15/2018
12.1.1 1,384 5/14/2018
12.1.0 1,350 5/9/2018
12.0.7 1,414 5/5/2018
12.0.6 1,424 5/4/2018
12.0.5 1,362 5/3/2018
12.0.4 1,408 4/30/2018
12.0.3 1,421 4/30/2018
12.0.2 1,354 4/27/2018
12.0.1 1,189 4/25/2018
12.0.0 1,197 4/22/2018
11.2.0 1,232 4/11/2018
11.1.0 1,407 4/8/2018
11.0.8 1,376 3/26/2018
11.0.7 1,353 3/20/2018
11.0.6 1,329 3/7/2018
11.0.5 1,223 2/22/2018
11.0.4 1,370 2/14/2018
11.0.3 1,343 2/12/2018
11.0.2 1,348 2/9/2018
11.0.1 1,210 1/29/2018
11.0.0 1,335 1/15/2018
10.0.3 1,646 12/29/2017
10.0.2 1,350 12/26/2017
10.0.1 1,391 12/18/2017
10.0.0 1,345 12/18/2017
9.3.0 1,332 12/17/2017
9.2.0 1,243 12/17/2017
9.1.3 1,270 12/5/2017
9.1.2 1,255 11/27/2017
9.1.1 1,236 11/21/2017
9.1.0 1,244 11/21/2017
9.0.1 1,287 11/11/2017
9.0.0 1,301 11/10/2017
8.7.0 1,273 11/9/2017
8.6.0 1,241 11/9/2017
8.5.0 1,258 10/3/2017
8.4.0 1,278 10/3/2017
8.3.1 1,747 9/8/2017
8.3.0 1,277 9/8/2017
8.2.0 1,245 9/4/2017
8.1.0 1,285 8/22/2017
8.0.0 1,424 8/19/2017
7.1.3 1,273 8/14/2017
7.1.2 1,320 8/2/2017