MsmqDistributor Service database logging problem

Topics: Logging Application Block
Jul 2, 2012 at 10:17 AM

I have installed and configured MsmqDistributedService to log events. Service works fine when using for example Event log listener. Now I tried to change it to database listener, but I get the following error when I try to start the service. All configurations are default created by configuration tool. Any ideas what might be wrong?

An error occurred while starting the service Enterprise Library Logging Distributor Service.
See 'Summary for Enterprise Library Logging Distributor Service' and additional 'Exception Information Details' below for more information. The service needs to be stopped.


Summary for Enterprise Library Distributor Service:
======================================
--> The Windows service initialization sequence has started.
--> MachineName: 
--> TimeStamp: 2.7.2012 9:59:06
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null
--> AppDomainName: MsmqDistributor.exe
--> WindowsIdentity: 

Exception Information Details:
======================================
Exception Type: System.Configuration.ConfigurationErrorsException
Message: Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'. (C:\Program Files\Microsoft\MsmqDistribution Service\MsmqDistributor.exe.config line 19)
BareMessage: Invalid TraceListenerData type in configuration 'listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'.
Filename: C:\Program Files\Microsoft\MsmqDistribution Service\MsmqDistributor.exe.config
Line: 19
Errors: System.Configuration.ConfigurationException[]
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)
HelpLink: NULL
Source: System.Configuration

StackTrace Information Details: 
======================================
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.DoGetSection(String sectionName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileBasedConfigurationSource.GetSection(String sectionName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.GetRegistrationsInternal(IConfigurationSource configurationSource, Func`3 registrationsAccessor)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<>c__DisplayClass5.b__4(ITypeRegistrationsProvider l)
   at System.Linq.Enumerable.d__14`2.MoveNext()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
   at Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.DistributorService.CreateListener(DistributorService distributorService, Int32 timerInterval, String msmqPath)
   at Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.DistributorService.InitializeComponent()

My configuration is

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<configSections>
		<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
		<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" />
		<section name="msmqDistributorSettings" type="Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.Configuration.MsmqDistributorSettings, MsmqDistributor"/>
	</configSections>

    <dataConfiguration defaultDatabase="Connection String" />
    <connectionStrings>
        <add name="Connection String" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=Logging;Integrated Security=SSPI;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
        <listeners>
            <add name="Database Trace Listener" 
		type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog"
                addCategoryStoredProcName="AddCategory" formatter="Text Formatter" traceOutputOptions="LogicalOperationStack, Timestamp" />
        </listeners>
        <formatters>
            <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                name="Text Formatter" />
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Database Trace Listener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings">
                <listeners>
                    <add name="Database Trace Listener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>

	<msmqDistributorSettings
		msmqPath=".\Private$\entlib_logging"
		queueTimerInterval="1000" 
		serviceName="Enterprise Library Distributor Service" />
</configuration>

Jul 3, 2012 at 4:09 AM

It sounds like you may be missing the Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll assembly from the MsmqDistributor.exe installation directory.

Can you verify that the assembly is deployed?  

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Jul 3, 2012 at 6:07 AM

Yes, the Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll was missing from installation directory. I added (copied) it and after that when I try to start the service I get following manifest exception. How would this be solved? I've build the library from source, without modifications, is there something I've missed when doing that? Everything else seems to be working fine.

An error occurred while starting the service Enterprise Library Logging Distributor Service.
See 'Summary for Enterprise Library Logging Distributor Service' and additional 'Exception Information Details' below for more information. The service needs to be stopped.


Summary for Enterprise Library Distributor Service:
======================================
--> The Windows service initialization sequence has started.
--> MachineName: 
--> TimeStamp: 3.7.2012 5:49:25
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null
--> AppDomainName: MsmqDistributor.exe
--> WindowsIdentity: 

Exception Information Details:
======================================
Exception Type: System.Configuration.ConfigurationErrorsException
Message: An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\Program Files\Microsoft\MsmqDistribution Service\MsmqDistributor.exe.config line 15)
BareMessage: An error occurred creating the configuration section handler for loggingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Filename: C:\Program Files\Microsoft\MsmqDistribution Service\MsmqDistributor.exe.config
Line: 15
Errors: System.Configuration.ConfigurationException[]
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)
HelpLink: NULL
Source: System.Configuration

StackTrace Information Details: 
======================================
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource.DoGetSection(String sectionName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileBasedConfigurationSource.GetSection(String sectionName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.GetRegistrationsInternal(IConfigurationSource configurationSource, Func`3 registrationsAccessor)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.GetRegistrations(IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.b__0(ITypeRegistrationsProvider l, IConfigurationSource cs)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<>c__DisplayClass5.b__4(ITypeRegistrationsProvider l)
   at System.Linq.Enumerable.d__14`2.MoveNext()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer(IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current()
   at Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.MsmqListener..ctor(DistributorService distributorService, Int32 timerInterval, String msmqPath)
   at Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.DistributorService.CreateListener(DistributorService distributorService, Int32 timerInterval, String msmqPath)
   at Microsoft.Practices.EnterpriseLibrary.Logging.MsmqDistributor.DistributorService.InitializeComponent()

Exception Information Details:
======================================
Exception Type: System.IO.FileLoadException
Message: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
FileName: Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog: WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Data: System.Collections.ListDictionaryInternal
TargetSite: Void GetTypeByName(System.String, Boolean, Boolean, Boolean, System.Runtime.CompilerServices.StackCrawlMarkHandle, Boolean, System.Runtime.CompilerServices.ObjectHandleOnStack)
HelpLink: NULL
Source: mscorlib

StackTrace Information Details: 
======================================
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName)
   at Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.TraceListenerDataCollection.RetrieveConfigurationElementType(XmlReader reader)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.PolymorphicConfigurationElementCollection`1.OnDeserializeUnrecognizedElement(String elementName, XmlReader reader)
   at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
Jul 3, 2012 at 6:23 AM

If you are building from source then the configuration information should not have the PublicKeyToken set to 31bf3856ad364e35 (this is the public key of Microsoft's certificate).  A default build from source will be unsigned so the PublicKeyToken will be null so set the configuration file to be PublicKeyToken=null in the configuration file.  Although, if you use the configuration tool that was built from source then it should use the correct PublicKeyToken.

Also, If you are using a build from source I'm surprised, based on the posted configuration, that the Event Log logging was working.  

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Jul 3, 2012 at 8:44 AM
Edited Jul 3, 2012 at 8:54 AM

Sorry, I was not clear enough in my previous post, I meant I build the Distributor service assembly from source not the entire library.

Anyway the event log logging and everything else is working. The database logging from distributor service does not work either because of the first exception or after copying the Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll assembly, then because the manifest problem. Logging to database without distributor service works, so I assume something is wrong with distributor service build or configuration.

Jul 4, 2012 at 3:59 AM

I would guess that the Distributor Service is referencing a different version of the Database Logging assembly (version number of public key token).  You can verify what is in the Distributor Service manifest by using the MSIL Disassembler (ildasm).  You can also check the assembly binds (and failures) using the Assembly Binding Log Viewer (fuslogvw).

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com