1

I am using Audit.WepApi (found here) with my .Net Core 2.2 application which is a Web API. I managed to configure it on my controllers using the default options. It is great for logging API calls which should hopefully add to the security aspect

However, I cannot seem to find any information about saving the logs to a SQL database. Or is there any program to make better sense of the .json files?

theJ
  • 395
  • 5
  • 25

1 Answers1

1

Here you can find the documentation index for the different data providers you can use to store the audit events.

For example you can reference the package Audit.Net.SqlServer and configure the provider via .UseSqlServer extension:

using Audit.Core;

Audit.Core.Configuration.Setup()
    .UseSqlServer(_ => _
        .ConnectionString("data source=...")
        .TableName("Event")
        .IdColumnName("EventId")
        .JsonColumnName("Data"));

You can also create your own data provider. Check the documentation here, for example:

public class MyCustomDataProvider : AuditDataProvider
{
    public override object InsertEvent(AuditEvent auditEvent)
    {
        var json = auditEvent.ToJson();
        // ...
    }
}
thepirat000
  • 12,362
  • 4
  • 46
  • 72
  • where we need to setup the providers, which file? – F11 Apr 11 '21 at 05:27
  • Depends on your project type, but it should be at the initialization of your application (before any audit takes place). For ASP.NET Core it could be on the `Startup` class. – thepirat000 Apr 11 '21 at 19:05