Logging Info write to DB

Topics: Logging Application Block
May 25, 2010 at 3:12 PM
Yesterday I try to logging to DB, but allways encount the error(I use the ver4.1), some one can help me: Description: Timestamp: 2010-5-25 13:57:31 Message: Tracing to LogSource 'General' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. Summary for Enterprise Library Distributor Service: ====================================== --> Message: Timestamp: 2010-5-25 13:57:31 Message: 4 Category: General Priority: -1 EventId: 1 Severity: Information Title: Machine: ZHANGWY-89BD18D App Domain: LogForDB.vshost.exe ProcessId: 2652 Process Name: D:\HomeSpace\SolutionForEntLib\LogForDB\bin\Debug\LogForDB.vshost.exe Thread Name: Win32 ThreadId:5836 Extended Properties: --> MachineName: ZHANGWY-89BD18D --> TimeStamp: 2010-5-25 13:57:31 --> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 --> AppDomainName: LogForDB.vshost.exe --> WindowsIdentity: ZHANGWY-89BD18D\zhangwy Exception Information Details: ====================================== Exception Type: System.Data.SqlClient.SqlException Errors: System.Data.SqlClient.SqlErrorCollection Class: 14 LineNumber: 65536 Number: 15350 Procedure: Server: \\.\pipe\B548041B-B8A3-47\tsql\query State: 1 Source: .Net SqlClient Data Provider ErrorCode: -2146232060 Message: 尝试为文件 D:\HomeSpace\SolutionForEntLib\LogForDB\bin\Debug\aspnetdb.mdf 附加自动命名的数据库,但失败。已存在同名的数据库,或指定的文件无法打开或位于 UNC 共享目录中。(In english it means:Try to attach the file of D:\HomeSpace\SolutionForEntLib\LogForDB\bin\Debug\aspnetdb.mdf,but fail.May exist the same time DB or the special file can not be open or the fiel is in the UNC share folder) Data: System.Collections.ListDictionaryInternal TargetSite: Void OnError(System.Data.SqlClient.SqlException, Boolean) HelpLink: NULL StackTrace Information Details: ====================================== 在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) 在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) 在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 在 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) 在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) 在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) 在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) 在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) 在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) 在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) 在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) 在 System.Data.SqlClient.SqlConnection.Open() 在 Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.ExecuteStoredProcedure(LogEntry logEntry) 位置 c:\Builds\EntLibV4\Latest\Source\Blocks\Logging\Src\DatabaseTraceListener\FormattedDatabaseTraceListener.cs:行号 143 在 Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) 位置(position) c:\Builds\EntLibV4\Latest\Source\Blocks\Logging\Src\DatabaseTraceListener\FormattedDatabaseTraceListener.cs:行号(line number) 89 在 Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter) 位置 c:\Builds\EntLibV4\Latest\Source\Blocks\Logging\Src\Logging\LogSource.cs:行号 160 在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.ProcessLog(LogEntry log) 位置 c:\Builds\EntLibV4\Latest\Source\Blocks\Logging\Src\Logging\LogWriter.cs:行号 478 Category: Priority: -1 EventId: 6352 Severity: Error Title: Machine: ZHANGWY-89BD18D Application Domain: LogForDB.vshost.exe Process Id: 2652 Process Name: D:\HomeSpace\SolutionForEntLib\LogForDB\bin\Debug\LogForDB.vshost.exe Win32 Thread Id: 5836 Thread Name: Extended Properties: Thanks very much
May 25, 2010 at 3:14 PM
And my app.config is: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </configSections> <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true"> <listeners> <add databaseInstanceName="LocalSqlServer" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Database Trace Listener" /> <add source="Enterprise Library Logging" formatter="Text Formatter" log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Formatted EventLog TraceListener" /> </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.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter" /> </formatters> <categorySources> <add switchValue="All" name="General"> <listeners> <add name="Database Trace Listener" /> <add name="Formatted EventLog TraceListener" /> </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="Formatted EventLog TraceListener" /> </listeners> </errors> </specialSources> </loggingConfiguration> </configuration>
May 25, 2010 at 3:33 PM
Oh, I have know it, I use the default connection string, in it, define to attach the aspnetdb.mdb. I creat a new connection and run again, it successful write the logging in DB :)