application-blockslogging-application-blocksemantic-logging

How to create database for a Semantic Logging Application Block with SqlDatabaseSink


How to set up the SQL Server database for Semantic logging. Does the table for logging information needs to be created earlier? If yes, what is the schema to be used.

I have the following code :

var listener = new ObservableEventListener();
string connectionString = @"Data Source=nibc2025;Initial Catalog=TreeDataBase;Integrated Security=True;User Id=sa;Password=nous@123";

listener.EnableEvents(AuditingEventSource.Log, EventLevel.LogAlways, Keywords.All);
databaseSubscription = listener.LogToSqlDatabase
(
    "Test",
    connectionString,
    "Traces",
    Buffering.DefaultBufferingInterval,
    1,
    Timeout.InfiniteTimeSpan, 500
);

// The following one line of code is not part of this function.
// It is just added here to show this is how I log my information.
// Inside LogInformation method I call the 'Write' method
AuditingEventSource.Log.LogInformation("sgsgg", "sgsg");

databaseSubscription.Sink.FlushAsync().Wait();

Solution

  • OK. I got it. the script was in the packages folder. I had overlooked that.