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

1.2k Views Asked by At

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();
2

There are 2 best solutions below

2
On BEST ANSWER

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

0
On

Well, Since this thread gets the most hits on Google regarding Semantic Logging onto SQL DB or even SLAB ...

The scripts to create the DB lies here

\packages\EnterpriseLibrary.SemanticLogging.Database.1.0.1304.0\scripts

And to create the EventSource and Fire the Blocks, information are given here, for a shortcut and quick fix solution

http://entlib.codeplex.com/discussions/540723

Regards,