Logging 企业库5数据库记录到平面文件工作,数据库不工作
我正在尝试将现有的EnterpriseLibrary5日志记录系统更改为使用数据库而不是平面文件提供程序。我已经使用配置工具生成了相关的配置部分,并将它们添加到我的配置文件中,但它似乎没有使用数据库,尽管平面文件仍在更新中。我的配置如下所示:Logging 企业库5数据库记录到平面文件工作,数据库不工作,logging,enterprise-library-5,Logging,Enterprise Library 5,我正在尝试将现有的EnterpriseLibrary5日志记录系统更改为使用数据库而不是平面文件提供程序。我已经使用配置工具生成了相关的配置部分,并将它们添加到我的配置文件中,但它似乎没有使用数据库,尽管平面文件仍在更新中。我的配置如下所示: <configSections> <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configura
<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" />
<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" />
</configSections>
<appSettings>
<add key="loggingenabled" value="true" />
<connectionStrings>
<add name="Localhost" connectionString="Database=Logging;Server=localhost;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="c:\logs\Service.log" header="" footer="" formatter="Text Formatter" rollSizeKB="102400" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Increment" rollInterval="None" />
<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="Localhost" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
traceOutputOptions="DateTime, ProcessId, ThreadId" />
</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(dd/MM/yyyy HH:mm:ss.fff)} {win32ThreadId} {category} {severity} {message}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Database Trace Listener" />
<add name="Flat File Trace Listener" />
</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="Database Trace Listener" />
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
应用程序或数据库中没有显示错误消息,但数据库是空的,并且没有任何尝试连接的迹象。如果我老实说,我不完全确定我做了什么来解决这个问题,但我成功地将错误消息从企业库中挤出。事实证明,尽管我编译了日志库,其中引用了Microsoft.Practices.EnterpriseLibrary.logging.Database,但我还必须向调用该库的WCF服务添加相同的引用—仅从日志系统引用它是不够的。如果我诚实的话,我不是绝对的当然,我做了什么来解决这个问题,但我还是设法从企业库中挤出了一条错误消息。事实证明,尽管我编译了日志库,其中引用了Microsoft.Practices.EnterpriseLibrary.logging.Database,但我还必须向调用该库的WCF服务添加相同的引用—仅从日志系统引用它是不够的