Database Logging throws error '{"Activation error occured while trying to get instance of type LogWr

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using Logging Application block (Ent Lib 5.0) through database trace listener. I just configured in web.config the required settings. The following is my web.config settings:
<pre class="prettyprint <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General
<listeners>
<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="LoggingConnectionString" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
traceOutputOptions="DateTime, Timestamp, ProcessId" />
</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: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="ErrorLogging
<listeners>
<add name="Database Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors &amp; Warnings
<listeners>
<add name="Database Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
<add name="AllExceptionsPolicy
<exceptionTypes>
<add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="NotifyRethrow
<exceptionHandlers>
<add name="AllExceptionsLoggingHandler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
logCategory="ErrorLogging" eventId="100" severity="Error"
title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
priority="0" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
<dataConfiguration defaultDatabase="LoggingConnectionString" />
<connectionStrings>
<add name="LoggingConnectionString" connectionString="Data Source=myservername;Initial Catalog=mycustomdatabase;User ID=sa;Password=admin23" />
</connectionStrings>[/code]
In code behind, I just wrote the following code:
<pre class="prettyprint LogEntry logentry = new LogEntry();
logentry.Message = "Starting the application";
logentry.EventId = 100;
logentry.Priority = 2;
Logger.Write(logentry);[/code]
Basically, I manually created the tables Category, categoryLog, Log tables in my custom database and also created all the stored procedures from Loggingdatabase.sql. Is this sufficient for database logging?
While trying to run the app, I am getting the error message "Activation error occured while trying to get instance of type LogWriter, key". Is this correct way of doing database logging? Am I missing something? Please help.
Thanks
<br/>

<hr class="sig meeram395

View the full article
 
Back
Top