Skip to main content
All docs
V24.1
.NET 6.0+

Audit Trail: Log Data Changes Made via Web API Endpoints

  • 3 minutes to read

You can use the following methods to enable the Audit Trail module in your applications.

Note

This option of our Web API Service ships as part of the DevExpress Universal Subscription.

Enable the Module in the Solution Wizard

If you create your Backend Web API project with the help of the Solution Wizard, a dedicated wizard screen allows you to enable the Audit Trail module. For additional information, see Create a Standalone Web API Application.

Enable the EF Core Audit Module in an Existing App

The general information about the EF Core Audit Module, refer to the following article:

Standalone Web API Application

Install the DevExpress.ExpressApp.AuditTrail.EFCore NuGet package.

Register the audited DBContext in Startup.cs.

services.AddXafWebApi(builder => {
    builder.Modules
        .AddAuditTrailEFCore();

    builder.ConfigureOptions(options => {
        //...
    });

    builder.ObjectSpaceProviders
        .AddSecuredEFCore()
        .WithAuditedDbContext(contexts => contexts.Configure<AppDbContext, AuditingDbContext>(
            (serviceProvider, options) => {
                string connectionString = Configuration.GetConnectionString("ConnectionString");
                options.UseSqlServer(connectionString);
                options.UseChangeTrackingProxies();
                options.UseObjectSpaceLinkProxies();
            },
            (serviceProvider, options) => {
                string connectionString = Configuration.GetConnectionString("ConnectionString");
                options.UseSqlServer(connectionString);
                options.UseChangeTrackingProxies();
                options.UseObjectSpaceLinkProxies();
            }
            ))
        .AddNonPersistent();
}, Configuration);

XAF Blazor Application

Install the DevExpress.ExpressApp.AuditTrail.EFCore NuGet package.

Register the Audit Trail module and required services in Startup.cs. Use the XAF Application builder:

services.AddXaf(Configuration, builder => {
    //..
    builder.Modules
        .AddAuditTrailEFCore()
    //...
}

Enable the XPO Audit Module in an Existing App

For general information about XPO Audit Module, refer to the following article:

Standalone Web API Application

Install the DevExpress.ExpressApp.AuditTrail.Xpo NuGet package.

Register the Audit Trail module and required services via the Web API builder in Startup.cs:

services.AddXafWebApi(builder => {
    builder.AddXpoServices();

    builder.Modules
        .AddAuditTrailXpo(options => {
            //...
        });
}, Configuration);

XAF Blazor Application

Install the DevExpress.ExpressApp.AuditTrail.Xpo NuGet package.

Register the Audit Trail module and required services via the XAF Application builder in Startup.cs:

services.AddXaf(Configuration, builder => {
    //..
    builder.Modules
        .AddAuditTrailXpo(options => {
            //...
        })
    //...
}

Query and Analyze Audit Log Stored in a Data Store

After you run CRUD operations with the help of Web API endpoints, audit log will be stored in the underlying database (AuditDataItemPersistent table). The Audit Module tracks built-in change operations (such as object creation, deletion, property modification), as well as any custom operations.

You can access the audit log with the help of any database management system (DBMS) that supports SQL query execution. Another option is to write code - use the API of your ORM tool:

Web API Service users who own the Universal Subscription can optionally create an administrative XAF WinForms, Blazor, or ASP.NET WebForms clients to view and analyze the Audit Log: