sqlTraceListeners eventtype information not written to db

Jan 7, 2011 at 1:33 AM

eventtype START/STOP

e.g.

using (mytracer.ProfileOperation(MethodBase.GetCurrentMethod().Name))

writes to db  but

eventtype INFORMATION does not.

switchvalue is set too ALL .

 

 

 

 

 

Coordinator
Jan 7, 2011 at 1:49 AM

Can you share your code and configuration – the relevant pieces only?

Thanks

Josh

Jan 7, 2011 at 6:38 PM

thanks, here it is:

 namespace WCFServiceNamespace

public class MyWcfServices : IMyWcfServices
    {

 private static ExtendedSource tracer = new ExtendedSource("WCFServiceNamespace");

        public string Method1()
        {
                 //this successfully writes the START /STOP to logstore
                using (tracer.ProfileOperation(MethodBase.GetCurrentMethod().Name))
            {

                  //these does not no matter where they appear in a method.

tracer.TraceEvent(TraceEventType.Information, 0,"traceMessage"); 

tracer.TraceInformation("Successfully completed {0} method", MethodBase.GetCurrentMethod().Name);  
          

webconfig file:

 

 <system.diagnostics>
    <sources>
      <source
        name="WCFServiceNamespace"
        switchValue="All">
        <listeners>
          <clear />
          <add  name="sql" />
        </listeners>
      </source>

 

(other config settings are from the project. )

 

Coordinator
Jan 7, 2011 at 6:40 PM

Could you also post your ukadcdiagnostics config section and the sharelisteners.

DON'T POST YOUR ConnectionString :)

Jan 7, 2011 at 9:46 PM

Thanks, it's odd that profileOperation method writes so i don't see it as a connectivity issue.Thanks for taking the time...jf

 

<configSections>
    <section
      name="The.Diagnostics"
      type="The.Diagnostics.Configuration.UkadcDiagnosticsSection, The.Diagnostics" />
  </configSections>

 

<add
      name="log"
      connectionString="Data Source=TheSqlServer,12345;Initial Catalog=Diagnostics_Log;Trusted_Connection=True;MultipleActiveResultSets=True"
      providerName="System.Data.SqlClient" />

 

 

<!-- Diagnostics logging section -->
  <The.Diagnostics>
    <sqlTraceListeners>
      <sqlTraceListener
        name="sqlTraceListenerSettings"
        connectionStringName="log"
        commandText="INSERT INTO LogStore VALUES(@Source, @ActivityId, @ProcessId, @ThreadId, @EventType, @Message, @Timestamp)"
        commandType="Text">
        <parameters>
          <parameter
            name="@Source"
            propertyToken="{Source}" />
          <parameter
            name="@ActivityId"
            propertyToken="{ActivityId}" />
          <parameter
            name="@ProcessId"
            propertyToken="{ProcessId}" />
          <parameter
            name="@ThreadId"
            propertyToken="{ThreadId}" />
          <parameter
            name="@EventType"
            propertyToken="{EventType}"
            callToString="true" />
          <parameter
            name="@Message"
            propertyToken="{Message}" />
          <parameter
            name="@Timestamp"
            propertyToken="{DateTime}" />
        </parameters>
      </sqlTraceListener>
    </sqlTraceListeners>

 <!-- SqlTraceListener -->

<add
        name="sql"
        initializeData="sqlTraceListenerSettings"
        type="The.Diagnostics.Listeners.SqlTraceListener, The.Diagnostics"
        traceOutputOptions="Timestamp" />
      <!-- SqlTraceListener -->

    <sharedListeners>
      <!-- SqlTraceListener -->
      <add
        name="sql"
        initializeData="sqlTraceListenerSettings"
        type="The.Diagnostics.Listeners.SqlTraceListener, The.Diagnostics"
        traceOutputOptions="Timestamp" />
      </add>
    </sharedListeners>
    <trace
      autoflush="true" />
  </system.diagnostics>

Coordinator
Jan 10, 2011 at 4:30 AM

Hi,

I've just tried to create a repro and it worked entirely as documented (using your code above, as much as possible).

Here's a simple repro showing it in action: TestingSqlListener.zip

The script for the DB table is at the bottom of the post. I noticed you have a The.Diagnostics namespace - have you customised the listeners at all. If you still can't get this working, I'll need a small portable repro (project like the one I linked to above) that demonstrates the problem.

Thanks

Josh

USE [Ukadc.Diagnostics]
GO

/****** Object:  Table [dbo].[LogStore]    Script Date: 01/09/2011 20:28:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[LogStore](
 [LogId] [int] IDENTITY(1,1) NOT NULL,
 [Source] [varchar](50) NULL,
 [ActivityId] [uniqueidentifier] NOT NULL,
 [ProcessId] [int] NOT NULL,
 [ThreadId] [varchar](50) NOT NULL,
 [EventType] [varchar](50) NOT NULL,
 [Message] [varchar](8000) NULL,
 [Timestamp] [datetime] NOT NULL,
 CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED
(
 [LogId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

 

Coordinator
Jan 12, 2011 at 8:02 PM

I'd love to know if you got this working?

Jan 13, 2011 at 12:31 AM

Yes, got it all working again. Thanks for you help. ok the issue was...project Build properties i did not have the Define TRACE constant enabled.