2012-02-17 82 views
1

我在使用企业库5.0登录到sql server 2008 Express时遇到问题 它在我的开发环境(VS2010)中工作,但不在我的Server 2008/SQL Server 2008 Express上。企业库5.0日志到sql server不工作

为了确保它不是我用平面文件测试过的数据库。也没有工作。

这两个文件都存在于我的bin目录中。

Microsoft.Practices.EnterpriseLibrary.Logging.dll Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll

我的web.config文件看起来是这样的:

<configSections> 
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /> 
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > 
    <section name="Space4it.Registertime.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
</sectionGroup> 
</configSections> 
<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="TimeseddelLogging" writeLogStoredProcName="WriteLog" 
    addCategoryStoredProcName="AddCategory" formatter="Text Formatter" 
    traceOutputOptions="LogicalOperationStack, DateTime, 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"> 
    <listeners> 
     <add name="Database Trace Listener" /> 
    </listeners> 
    </allEvents> 
    <notProcessed switchValue="All" name="Unprocessed Category" /> 
    <errors switchValue="All" name="Logging Errors &amp; Warnings"> 
    <listeners> 
     <add name="Database Trace Listener" /> 
    </listeners> 
    </errors> 
</specialSources> 
</loggingConfiguration> 
<connectionStrings> 
<add name="TimeseddelLogging" connectionString="Data Source=server\sqlexpress;Initial Catalog=logging.database;User ID=username;pwd=password"/> 
</connectionStrings> 

我手动连接(作为测试)使用该用户和我能够在日志表中与该用户输入数据。

我得到这个错误: 异常:

消息:

Activation error occured while trying to get instance of type LogWriter, key ""

堆栈:

at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstanceTService at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer() at Space4it.Common.Log.Log.DoLog(String message, String category, Dictionary`2 metaData, Exception ex, TraceEventType type, LogPriority priority, Int32 eventId) at Space4it.Registertime.Pages.TestForm.ButtonTest_Click(Object sender, EventArgs e)

内部异常: 消息:

Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter", name = "(none)". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value. ----------------------------------------------- At the time of the exception, the container was: Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.default (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none)) Resolving parameter "structureHolder" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator) Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.default (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, (none)) Resolving parameter "traceSources" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable 1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters, System.Collections.Generic.IEnumerable 1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable 1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategory, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonation) Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General Resolving parameter "traceListeners" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name, System.Collections.Generic.IEnumerable 1[[System.Diagnostics.TraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider) Resolving Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,Database Trace Listener (mapped from System.Diagnostics.TraceListener, Database Trace Listener) Resolving parameter "wrappedTraceListener" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener wrappedTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator coordinator) Resolving Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,Database Trace Listener‌implementation (mapped from System.Diagnostics.TraceListener, Database Trace Listener‌implementation) Resolving parameter "database" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(Microsoft.Practices.EnterpriseLibrary.Data.Database database, System.String writeLogStoredProcName, System.String addCategoryStoredProcName, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter) Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,TimeseddelLogging

内部异常堆栈:

at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable 1 resolverOverrides) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable 1 resolverOverrides) at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)

希望有人能帮助我:-)

有一个愉快的一天!

+0

有非常类似的问题。你有没有在StackOverflow之外找到解决方案? – 2012-07-18 17:55:13

回答

1

你得到的错误是指示Entlib没有正确初始化自己。该数据库是一个红鲱鱼 - 你现在还没有得到日志块的工作。

是否在web.config文件的< configSections>元素中定义了日志记录部分?

更新:

你加入你的configSections元素,但你发布的格式不正确:< configSections> </sectionGroup>。如果这是准确的,那么这就是问题,格式错误的配置。修复关闭标记,它应该开始工作。

+0

嗨克里斯。 感谢您的回复。 我在我的描述中增加了一些,但我认为没关系。它适用于我的开发环境。 它可能是一个X86/64的问题? 我编译为AnyCPU,但我无法弄清楚当它运行在X64系统的2008 Server上时Entlib是否有问题。 我没有尝试编译为X64,但没有锁定。 – 2012-02-18 10:51:51

+0

entlib团队都使用64位机器开发,所以不,它不是32位和64位的问题。 – 2012-02-18 18:08:26

+0

配置错误是一个粘贴错误。 现在应该看起来不错。 应用程序的其余部分工作。我只有记录问题。 难道是我需要更多的2 Logging.dll文件? – 2012-02-19 10:11:16