Audit.NET.PostgreSql 27.0.1

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

// Install Audit.NET.PostgreSql as a Cake Tool
#tool nuget:?package=Audit.NET.PostgreSql&version=27.0.1                

Audit.NET.PostgreSql

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

Store the audit events in a PostgreSQL Table, in JSON format.

Install

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

PM> Install-Package Audit.NET.PostgreSql

NuGet Status NuGet Count

Usage

Please see the Audit.NET Readme

Configuration

Set the static Audit.Core.Configuration.DataProvider property to set the PostgreSQL data provider, or call the UsePostgreSql 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 PostgreSqlDataProvider()
{
    ConnectionString = "Server=127.0.0.1;Port=5432;User Id=admin;Password=admin;Database=postgres;",
    TableName = "event",
    IdColumnName = "id",
    DataColumnName = "data",
    DataType = "JSONB",
    LastUpdatedDateColumnName = "updated_date",
    CustomColumns = new List<CustomColumn>()
    {
        new CustomColumn("event_type", ev => ev.EventType),
        new CustomColumn("user", ev => ev.Environment.UserName),
    }
};

Or by using the fluent configuration API:

Audit.Core.Configuration.Setup()
    .UsePostgreSql(config => config
        .ConnectionString("Server=127.0.0.1;Port=5432;User Id=admin;Password=admin;Database=postgres;")
        .TableName("event")
        .IdColumnName("id")
        .DataColumn("data", DataType.JSONB)
        .LastUpdatedColumnName("updated_date")
        .CustomColumn("event_type", ev => ev.EventType)
        .CustomColumn("user", ev => ev.Environment.UserName));

Provider Options

Mandatory:

  • ConnectionString: The PostgreSQL Server connection string.
  • TableName: The events table name.
  • DataColumnName: The column name of the event table where the JSON will be stored.
  • IdColumnName: The column name of the event identifier (the primary key).

Optional:

  • Schema: The PostgreSQL schema to use.
  • DataType: The type of the data column that stores the events. Can be JSON, JSONP or STRING. (Default is JSON).
  • LastUpdatedDateColumnName: The datetime column name to update when replacing events.
  • CustomColumn: Additional columns to store information from the audit event. (optional)

Table constraints

  • The table must exists.
  • The table must have a single ID column (Unique or Primary key).
  • The type of the ID column must be convertible to STRING.

For example:

CREATE TABLE public.event
(
    id bigserial NOT NULL,
    inserted_date timestamp without time zone NOT NULL DEFAULT now(),
    updated_date timestamp without time zone NOT NULL DEFAULT now(),
    data jsonb NOT NULL,
    event_type varchar(50),
    user varchar(50) NULL,
    CONSTRAINT event_pkey PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

Query events

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

var event = dataProvider.GetEvent(1000);

The Postgre SQL data provider also includes basic support for querying the events collection.

Use the EnumerateEvents() method on PostgreSqlDataProvider class to run SQL-like queries against the audit events. The EnumerateEvents() method accepts any valid Postgre WHERE clause as a parameter.

For example:

IEnumerable<AuditEvent> events = postgreDataProvider.EnumerateEvents(
       "data #> '{Environment,UserName}' = '\"John\"'");

Will return the events whose property Environment.UserName is equal to 'John'.

This post contains information about the query syntax supported by JSONP data type. And here is the PostgreSQL documentation about JSON operators.

For complex querying capabilities, you should use the npgsql driver or the Npgsql EntityFramework provider directly.

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. 
.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 is compatible. 
.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 (4)

Showing the top 4 NuGet packages that depend on Audit.NET.PostgreSql:

Package Downloads
Reo.Core.AutoHistory

Package Description

Dalmarkit.AspNetCore

Dalmarkit is an opinionated .NET utility library that simplifies the building of AWS Cognito secured JSON REST APIs with audit trails using ASP.NET Core and Entity Framework Core with PostgreSQL.

edyo_infrastructure

Package Description

Reo.Core.AutoHistory.31

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
27.0.3 303 9/25/2024
27.0.2 3,339 9/19/2024
27.0.1 1,057 9/4/2024
27.0.0 293 9/3/2024
26.0.1 6,143 8/22/2024
26.0.0 18,226 7/19/2024
25.0.7 19,739 7/4/2024
25.0.6 1,211 6/24/2024
25.0.5 447 6/18/2024
25.0.4 89,227 3/24/2024
25.0.3 1,189 3/13/2024
25.0.2 263 3/12/2024
25.0.1 10,838 2/28/2024
25.0.0 76,090 2/16/2024
24.0.1 1,219 2/12/2024
24.0.0 119 2/12/2024
23.0.0 80,699 12/14/2023
22.1.0 5,303 12/9/2023
22.0.2 4,159 12/1/2023
22.0.1 29,886 11/16/2023
22.0.0 406 11/14/2023
21.1.0 35,376 10/9/2023
21.0.4 15,289 9/15/2023
21.0.3 37,273 7/9/2023
21.0.2 195 7/6/2023
21.0.1 26,899 5/27/2023
21.0.0 67,449 4/15/2023
20.2.4 37,643 3/27/2023
20.2.3 125,259 3/17/2023
20.2.2 7,128 3/14/2023
20.2.1 333 3/11/2023
20.2.0 686 3/7/2023
20.1.6 58,358 2/23/2023
20.1.5 2,333 2/9/2023
20.1.4 43,320 1/28/2023
20.1.3 61,025 12/21/2022
20.1.2 3,737 12/14/2022
20.1.1 4,490 12/12/2022
20.1.0 1,908 12/4/2022
20.0.4 2,293 11/30/2022
20.0.3 5,191 10/28/2022
20.0.2 633 10/26/2022
20.0.1 2,903 10/21/2022
20.0.0 4,139 10/1/2022
19.4.1 7,429 9/10/2022
19.4.0 1,510 9/2/2022
19.3.0 2,875 8/23/2022
19.2.2 3,789 8/11/2022
19.2.1 614 8/6/2022
19.2.0 1,913 7/24/2022
19.1.4 12,103 5/23/2022
19.1.3 525 5/22/2022
19.1.2 1,459 5/18/2022
19.1.1 38,363 4/28/2022
19.1.0 54,170 4/10/2022
19.0.7 25,759 3/13/2022
19.0.6 1,255 3/7/2022
19.0.5 20,903 1/28/2022
19.0.4 1,071 1/23/2022
19.0.3 20,898 12/14/2021
19.0.2 1,666 12/11/2021
19.0.1 2,048 11/20/2021
19.0.0 2,416 11/11/2021
19.0.0-rc.net60.2 1,094 9/26/2021
19.0.0-rc.net60.1 233 9/16/2021
18.1.6 773,316 9/26/2021
18.1.5 42,036 9/7/2021
18.1.4 32,824 9/6/2021
18.1.3 5,240 8/19/2021
18.1.2 1,241 8/8/2021
18.1.1 480 8/5/2021
18.1.0 926 8/1/2021
18.0.1 511 7/30/2021
18.0.0 522 7/26/2021
17.0.8 15,543 7/7/2021
17.0.7 739 6/16/2021
17.0.6 619 6/5/2021
17.0.5 742 5/28/2021
17.0.4 3,132 5/4/2021
17.0.3 525 5/1/2021
17.0.2 8,546 4/22/2021
17.0.1 500 4/18/2021
17.0.0 983 3/26/2021
16.5.6 531 3/25/2021
16.5.5 6,509 3/23/2021
16.5.4 734 3/9/2021
16.5.3 521 2/26/2021
16.5.2 503 2/23/2021
16.5.1 3,445 2/21/2021
16.5.0 7,343 2/17/2021
16.4.5 510 2/15/2021
16.4.4 928 2/5/2021
16.4.3 514 1/27/2021
16.4.2 4,219 1/22/2021
16.4.1 560 1/21/2021
16.4.0 1,212 1/11/2021
16.3.3 569 1/8/2021
16.3.2 572 1/3/2021
16.3.1 581 12/31/2020
16.3.0 539 12/30/2020
16.2.1 4,443 12/27/2020
16.2.0 18,059 10/13/2020
16.1.5 683 10/4/2020
16.1.4 3,981 9/17/2020
16.1.3 1,714 9/13/2020
16.1.2 586 9/9/2020
16.1.1 1,161 9/3/2020
16.1.0 674 8/19/2020
16.0.3 711 8/15/2020
16.0.2 13,358 8/9/2020
16.0.1 628 8/8/2020
16.0.0 1,780 8/7/2020
15.3.0 291,251 7/23/2020
15.2.3 2,816 7/14/2020
15.2.2 50,971 5/19/2020
15.2.1 3,714 5/12/2020
15.2.0 656 5/9/2020
15.1.1 641 5/4/2020
15.1.0 2,578 4/13/2020
15.0.5 772 3/18/2020
15.0.4 684 2/28/2020
15.0.3 598 2/26/2020
15.0.2 4,807 1/20/2020
15.0.1 728 1/10/2020
15.0.0 718 12/17/2019
14.9.1 720 11/30/2019
14.9.0 671 11/29/2019
14.8.1 661 11/26/2019
14.8.0 854 11/20/2019
14.7.0 965 10/9/2019
14.6.6 678 10/8/2019
14.6.5 37,886 9/27/2019
14.6.4 630 9/21/2019
14.6.3 5,399 8/12/2019
14.6.2 785 8/3/2019
14.6.1 703 8/3/2019
14.6.0 724 7/26/2019
14.5.7 729 7/18/2019
14.5.6 1,061 7/10/2019
14.5.5 700 7/1/2019
14.5.4 697 6/17/2019
14.5.3 756 6/5/2019
14.5.2 734 5/30/2019
14.5.1 7,465 5/28/2019
14.5.0 2,701 5/24/2019
14.4.0 767 5/22/2019
14.3.4 2,210 5/14/2019
14.3.3 719 5/9/2019
14.3.2 881 4/30/2019
14.3.1 751 4/27/2019
14.3.0 5,526 4/24/2019
14.2.3 864 4/17/2019
14.2.2 735 4/10/2019
14.2.1 15,993 4/5/2019
14.2.0 759 3/16/2019
14.1.1 751 3/8/2019
14.1.0 2,078 2/11/2019
14.0.4 2,765 1/31/2019
14.0.3 5,873 1/22/2019
14.0.2 1,409 12/15/2018
14.0.1 898 11/29/2018
14.0.0 913 11/19/2018
13.3.0 949 11/16/2018
13.2.2 909 11/15/2018
13.2.1 2,867 11/13/2018
13.2.0 999 10/31/2018
13.1.5 918 10/31/2018
13.1.4 953 10/25/2018
13.1.3 941 10/18/2018
13.1.2 1,099 9/12/2018
13.1.1 987 9/11/2018
13.1.0 978 9/11/2018
13.0.0 1,045 8/29/2018
12.3.6 1,016 8/29/2018
12.3.5 1,036 8/22/2018
12.3.4 1,425 8/21/2018
12.3.3 25,783 8/21/2018
12.3.2 1,034 8/20/2018
12.3.1 1,040 8/20/2018
12.3.0 1,038 8/20/2018
12.2.2 1,077 8/15/2018
12.2.1 1,059 8/9/2018
12.2.0 994 8/8/2018
12.1.11 1,011 7/30/2018
12.1.10 1,088 7/20/2018
12.1.9 1,130 7/10/2018
12.1.8 1,030 7/2/2018
12.1.7 1,191 6/7/2018
12.1.6 1,155 6/4/2018
12.1.5 1,134 6/2/2018
12.1.4 1,203 5/25/2018
12.1.3 1,242 5/16/2018
12.1.2 1,087 5/15/2018
12.1.1 1,215 5/14/2018
12.1.0 1,338 5/9/2018
12.0.7 1,253 5/5/2018
12.0.6 1,251 5/4/2018
12.0.5 1,195 5/3/2018
12.0.4 1,188 4/30/2018
12.0.3 1,233 4/30/2018
12.0.2 1,141 4/27/2018
12.0.1 1,215 4/25/2018
12.0.0 1,135 4/22/2018
11.2.0 1,115 4/11/2018
11.1.0 1,199 4/8/2018
11.0.8 1,177 3/26/2018
11.0.7 1,163 3/20/2018
11.0.6 1,167 3/7/2018
11.0.5 1,111 2/22/2018
11.0.4 1,219 2/14/2018
11.0.3 1,148 2/12/2018
11.0.2 1,141 2/9/2018
11.0.1 1,102 1/29/2018
11.0.0 1,141 1/15/2018
10.0.3 1,093 12/29/2017
10.0.2 1,142 12/26/2017
10.0.1 1,155 12/18/2017
10.0.0 1,062 12/18/2017
9.3.0 1,175 12/17/2017
9.2.0 1,134 12/17/2017
9.1.3 1,160 12/5/2017
9.1.2 1,119 11/27/2017
9.1.1 1,132 11/21/2017
9.1.0 1,091 11/21/2017
9.0.1 1,087 11/11/2017
9.0.0 1,136 11/10/2017
8.7.0 1,144 11/9/2017
8.6.0 1,142 11/9/2017
8.5.0 1,159 10/3/2017
8.4.0 1,234 10/3/2017