Nov 30, 2014 at 6:59 PM
Edited Nov 30, 2014 at 7:30 PM
I'm testing the Semantic Logging and trying to setup a database log in a console application with the following command:
var cs = ConfigurationManager.ConnectionStrings["Traces"];
var listener = SqlDatabaseLog.CreateListener( "GEOVIXEL", cs.ConnectionString,
bufferingInterval: TimeSpan.FromSeconds( 3 ), bufferingCount:10 );
listener.EnableEvents( GvxEventSource.Log, EventLevel.Verbose, Keywords.All );
(Yes the database exists and yest the table and stored procedure are created.)
The connection string is coming from the app.config as follow:
<add name="Traces" connectionString="Data Source=(localDB)\v11.0;Initial Catalog=TestLog; Integrated Security=True" providerName="System.Data.SqlClient" />
I also setup a console and flat file logs that works well.
I'm not getting any error whit the setup but the table is empty. (Yes I dispose and even wait 10 seconds before exit to make sure).
The funny part is that it works fine in the out-of-process logging with the following configuration:
<!-- Database Events -->
connectionString ="Data Source=(localDB)\v11.0;Initial Catalog=TestLog;Integrated Security=True">
What am I doing wrong? It's one line of code configuration!!! Using the same connection string!
UPDATE: Adding the FLushAsync before exit I can see now that there's an exception that is thrown: "Trying to pass a table-valued parameter with 16 column(s) where the corresponding user-defined table type requires 12 column(s)."
The table does have 12 columns. Why the logger's trying to write 16? Do I have the correct script to create the table?
CREATE TABLE [dbo].[Traces](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[InstanceName] [nvarchar](1000) NOT NULL,
[ProviderId] [uniqueidentifier] NOT NULL,
[ProviderName] [nvarchar](500) NOT NULL,
[EventId] [int] NOT NULL,
[EventKeywords] [bigint] NOT NULL,
[Level] [int] NOT NULL,
[Opcode] [int] NOT NULL,
[Task] [int] NOT NULL,
[Timestamp] [datetimeoffset](7) NOT NULL,
[Version] [int] NOT NULL,
[FormattedMessage] [nvarchar](4000) NULL,
[Payload] [nvarchar](4000) NULL,
CONSTRAINT [PK_Traces] PRIMARY KEY CLUSTERED
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF)