Overview

The Enterprise Library extension supports v5.0 of the Logging Application Block. However if you need to support an older version, then you will need to download the ReflectInsight Logging Extensions Library source from CodePlex and rebuild it against a specific release of the Enterprise Library. (Note: if you use the Nuget Package, the update to the latest version of Enterprise Library Logging framework will be automatic).

Enterprise Library Configuration

1. Download and install the ReflectInsight Viewer. You will need this installed to view your messages from the ReflectInsight Logging Extensions.

Download

2. Download the ReflectInsight Extension Binaries or Source and rebuild if necessary. Alternatively you can use the NuGet package. See below for details on the NuGet package.

NOTE: If you have added the Enterprise Library Extension from the NuGet gallery, then you can skip step #3 as it's already done for you.

3. Once you have the ReflectInsight Extensions, go to your project in Visual Studio and add a reference to the following assemblies:

  • ReflectSoftware.Insight.dll
  • ReflectSoftware.Insight.Extensions.EnterpriseLibrary.dll

EnterpriseLibrary_Adding_Assembly.png
4. The next step is to configure your app or web configuration file and incorporate the ReflectInsight appender. If you don't already have an App.config or Web.config, add it. Then open the configuration file and add a new ConfigSection as shown here:

<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" requirePermission="true" />
    <section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight"/>
  </configSections>
</configuration>

5. Now you will need to add the InsightSettings section. You can get started with the following simple configuration:

<configuration>
  <insightSettings>
    <baseSettings>
      <configChange enabled="true"/>
      <propagateException enabled="false"/>
      <exceptionEventTracker time="20"/>
      <debugMessageProcess enabled="true" />
    </baseSettings>

    <listenerGroups active="Debug">
      <group name="Debug" enabled="true" maskIdentities="false">
        <destinations>
          <destination name="Viewer" enabled="true" filter="" details="Viewer"/>
        </destinations>
      </group>
    </listenerGroups>

    <!-- Log Manager -->
    <logManager>
      <instance name="EntLibInstance" category="EntLib"/>
    </logManager>
  </insightSettings>
</configuration>

6. Now you need to configure your Enterprise Library configuration with a reference to the ReflectInsight Appender. Update your Enterprise Library section with the following:

<configuration>
  <loggingConfiguration tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
            type="ReflectSoftware.Insight.Extensions.EnterpriseLibrary.Tracer.RICustomTracer, ReflectSoftware.Insight.Extensions.EnterpriseLibrary"
            Extension="EntLibInstance"
            name="RICustomTracer" />
      <add name="Event Log Listener"
            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"
            log=""
            machineName="."
            traceOutputOptions="None" />
    </listeners>

    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="RICustomTracer" />
        </listeners>
      </add>
    </categorySources>

    <specialSources>
      <allEvents switchValue="All" name="All Events">
        <listeners>
          <add name="Event Log Listener" />
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Event Log Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
</configuration>


NOTE: If you have your Enterprise Library configuration differently, then just make sure you update it to include the above details.

8. If you're using Enterprise Library Logging Application Block v6, then you need to do the following:

Add the following to your using statements and if necessary add them as references to your applicatoin

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;

Then add the following to initialize the EntLib logging:

IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
Logger.SetLogWriter(logWriterFactory.Create());


9. Alternatively you can look at the configuration files that are part of the sample application.

10. That's it, you're done!

NuGet Package

We've created a NuGet package for our Enterprise Library extension. You can find it over on Nuget.

To install ReflectSoftware.Insight.Extensions.EnterpriseLibrary extension, run the following command in the Package Manager Console.

sshot-325.png

Last edited Jul 22, 2013 at 4:08 AM by RSDeveloper, version 29