Logging Application Block

Dec 6, 2011 at 1:31 PM

HI,

I am not able to log the messages through Logging Application Block and got the Activation Exception error "Activation error occured while trying to get instance of type LogWriter, key """ which has been resolved by adding the TypeRegistrationProvidersConfiguration under the configuration section of the config file. Now the activation error is resolved but the messages are not logged with respect to the logger configured in the config file.

Below is the configuration information which i used in my project.

<?xml version="1.0"?>

<configuration>

       <configSections>

              <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" requirePermission="true"/>

       </configSections>

 

       <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

              <listeners>

                     <add name="Formatted EventLog TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"

           listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"

           source="Enterprise Library Logging" formatter="Text Formatter" log="Application" machineName="" traceOutputOptions="None" filter="All"/>

              </listeners>

              <formatters>

                     <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging" template="Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}{newline}Priority: {priority}{newline}EventId: {eventid}{newline}Severity: {severity}{newline}Title: {title}{newline}Activity ID: {property(ActivityId)}{newline}Machine: {localMachine}{newline}App Domain: {localAppDomain}{newline}ProcessId: {localProcessId}{newline}Process Name: {localProcessName}{newline}Thread Name: {threadName}{newline}Win32 ThreadId:{win32ThreadId}{newline}Extended Properties: {dictionary({key} - {value}{newline})}"

           name="Text Formatter"/>

              </formatters>

              <logFilters>

                     <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging" minimumPriority="2" maximumPriority="99" name="Priority Filter"/>

                     <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging" enabled="true" name="LogEnabled Filter"/>

                     <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging" categoryFilterMode="AllowAllExceptDenied" name="Category Filter">

                           <categoryFilters>

                                  <add name="BlockedByFilter"/>

                           </categoryFilters>

                     </add>

              </logFilters>

              <categorySources>

                     <add switchValue="All" name="BlockedByFilter">

                           <listeners>

                                  <add name="Formatted EventLog TraceListener"/>

                           </listeners>

                     </add>

                     <add switchValue="All" name="General">

                           <listeners>

                                  <add name="Formatted EventLog TraceListener"/>

                           </listeners>

                     </add>

              </categorySources>

              <specialSources>

                     <allEvents switchValue="All" name="All Events"/>

                     <notProcessed switchValue="All" name="Unprocessed Category">

                           <listeners>

                                  <add name="UnprocessedFlatFile"/>

                           </listeners>

                     </notProcessed>

                     <errors switchValue="All" name="Logging Errors &amp; Warnings">

                           <listeners>

                                  <add name="Formatted EventLog TraceListener"/>

                           </listeners>

                     </errors>

              </specialSources>

       </loggingConfiguration>

       </configuration>

Please help. Thanks in advance.

Deepa.