使用Enterprise Library 4.0 Logging 的问题?

cooolchen 2008-08-23 09:28:43
将应用程序日志写近数据库里面遇到了如下的错误,配置文件见下文。

配置过Enterprise Library的朋友请帮个忙!


先放20分,解决了后再加分。。。。

---------------------------
Application Error
---------------------------
The following error occured during execution of the Logging QuickStart.

创建 loggingConfiguration 的配置节处理程序时出错: 未能加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040) (F:\EntLib4Src\Quick Starts\Logging\CS\LoggingQuickStart\bin\Debug\LoggingQuickStart.vshost.exe.Config line 3)

Exceptions can be caused by invalid configuration information.




<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Database Trace Listener" />
<add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="LoggingQuickStart.DebugTraceListener, LoggingQuickStart"
name="Debug Destination" initializeData="" formatter="Text Formatter" />
<add source="Logging Quick Start" formatter="Text Formatter"
log="" machineName="." listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Event Log Destination" />
<add fileName="trace.log" header="----------------header------------------------"
footer="----------------footer------------------------" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Flat File Destination" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp} Message: {message} Category: {category} Priority: {priority} EventId: {eventid} Severity: {severity} Title:{title} Machine: {machine} Application Domain: {appDomain} Process Id: {processId} Process Name: {processName} Win32 Thread Id: {win32ThreadId} Thread Name: {threadName} Extended Properties: {dictionary({key} - {value} )}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
</formatters>
<logFilters>
<add categoryFilterMode="AllowAllExceptDenied" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Category">
<categoryFilters>
<add name="UI Events" />
<add name="DataBaseByChW" />
<add name="Debug" />
<add name="General" />
<add name="Data Access Events" />
<add name="Troubleshooting" />
<add name="Trace" />
</categoryFilters>
</add>
<add minimumPriority="2" maximumPriority="2147483647" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Priority" />
<add enabled="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="LogEnabled Filter" />
</logFilters>
<categorySources>
<add switchValue="All" name="Data Access Events">
<listeners>
<add name="Flat File Destination" />
</listeners>
</add>
<add switchValue="All" name="DataBaseByChW">
<listeners>
<add name="Database Trace Listener" />
</listeners>
</add>
<add switchValue="All" name="Debug">
<listeners>
<add name="Debug Destination" />
</listeners>
</add>
<add switchValue="All" name="General">
<listeners>
<add name="Event Log Destination" />
</listeners>
</add>
<add switchValue="All" name="Trace">
<listeners>
<add name="Flat File Destination" />
</listeners>
</add>
<add switchValue="All" name="Troubleshooting">
<listeners>
<add name="Event Log Destination" />
</listeners>
</add>
<add switchValue="All" name="UI Events">
<listeners>
<add name="Flat File Destination" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Event Log Destination" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<connectionStrings>
<add name="Connection String" connectionString="Database=Logging;Server=DM0124\SQLEXPRESS;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
...全文
443 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jvhmr 2009-02-16
  • 打赏
  • 举报
回复
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />


修改为

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging />


搞定...
cacar2008 2008-12-21
  • 打赏
  • 举报
回复
不过我发现一个更简单的方法,就是你先不要编辑这些配置文件,用Enterprise Library Configuration 工具重新打开一次,然后保存。如果你是强名的,Enterprise Library Configuration就会自动将Version, Culture, PublicKeyToKen给你加上。不过强名之后,运行QuickStarts中的例子是非常有趣的,这个是后话,不说了J
cacar2008 2008-12-21
  • 打赏
  • 举报
回复
鄙夷版本不一致
lyq888 2008-09-04
  • 打赏
  • 举报
回复
是啊.遇到同样的问题,把PublicKeyToken=31bf3856ad364e35全部更改为PublicKeyToken=null就没问题了,原因正在查找中....
tqz2003 2008-08-30
  • 打赏
  • 举报
回复
把 PublicKeyToken=31bf3856ad364e35
改为 PublicKeyToken=null
cooolchen 2008-08-24
  • 打赏
  • 举报
回复
高手呢?

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧