Database Trace Listener not logging to database

Topics: Logging Application Block
Dec 1, 2008 at 9:54 PM

<

section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

 

<

loggingConfiguration name="Logging Application Block" tracingEnabled="true"

 

 

defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

 

<

listeners>

 

<

add databaseInstanceName="Logging" writeLogStoredProcName="WriteLog"

 

 

addCategoryStoredProcName="AddCategory" 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" />
etc...

 

<

connectionStrings>

 

<

add name="Logging" connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=Logging;Integrated Security=True"

 

 

 

 

providerName="System.Data.SqlClient" />

 

 

</connectionStrings>

 

 


in page_load:

 

 

LogEntry log = new LogEntry();

 

log.Message =

"Testing Logging";

 

log.Categories.Add(

"Project1");

 

 

Logger.Write(log);

 

Dec 2, 2008 at 6:25 AM
Hi,

I cant find the part in your config which you have created a category with a name "Project1". If that is what you're missing, you should.

Add a new category named "Project1" then under that category you should add a trace listener reference which references your database trace listener.


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Dec 3, 2008 at 12:42 AM
Try adding a data configuratin block.  (Don't forget to register the dataConfiguration section.)

<dataConfiguration defaultDatabase="Logging" />

HTH,
An