MilkTea027
MilkTea027

Reputation: 301

EnterpriseLibrary Logging to Database not working

I have the following in my config:

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="Exception Development">
        <listeners>
          <add name="Database Trace Listener"
               formatter="Text Formatter"
                traceoutputoptions="LogicalOperationStack, DateTime, 
                                      Timestamp, ProcessId, ThreadId, Callstack"
                databaseinstancename="LoggingConnectionString"
                writelogstoredprocname="WriteLog"
                addcategorystoredprocname="AddCategory"
                type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.
                        FormattedDatabaseTraceListener, 
                        Microsoft.Practices.EnterpriseLibrary.Logging.Database, 
                        Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                listenerdatatype="Microsoft.Practices.EnterpriseLibrary.Logging.
                                    Database.Configuration.FormattedDatabaseTraceListenerData, 
                                    Microsoft.Practices.EnterpriseLibrary.Logging.Database, 
                                   Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

When hit this line of code: ExceptionPolicy.HandleException(exception, policyName);

It throws the following exception:

Missing TraceListenerData type in configuration 'listenerdatatype="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData,Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"'.

I'm not really sure how to log the exception to the database (I haven't exactly created any stored procedure that was in the writeLogStoredProcName or in the addCategoryStoredProcName (am I suppose to? I don't even know what columns should go in there)

All my EnterpriseLibrary dlls are all from EntLib 5.0. What could I be doing wrong? (I even included them in the References folder.

EDIT:
I included the following dlls already:

Microsoft.Practices.EnterpriseLibrary.Common;
Microsoft.Practices.EnterpriseLibrary.Data;
Microsoft.Practices.EnterpriseLibrary.Data.SqlCe;
Microsoft.Practices.EnterpriseLibrary.Logging;
Microsoft.Practices.EnterpriseLibrary.Logging.Database;
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;

still no luck!!

Upvotes: 2

Views: 2067

Answers (1)

Randy Levy
Randy Levy

Reputation: 22655

You are seeing that message because the Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll assembly is not deployed to the output folder (bin or bin\debug|release). This happens because since the assembly is only referenced in configuration Visual Studio doesn't think it is required. A post build command can deploy the assembly.

Upvotes: 1

Related Questions