Overview

We've added support for the NLog appender. This allows you to leverage your current investment in NLog, but leverage the power and flexibility that comes with the ReflectInsight viewer. You can view your NLog messages in realtime, in a rich viewer that allows you to filter out and search for what really matters to you.

The NLog extension supports v2.0.0.2. However if you need to support an older version, then you will need to download the ReflectInsight Logging Extensions Library from CodePlex. You can then reference and rebuild the extension against your a specific release of the NLog dll. (Note: if you use the Nuget Package, the update to the latest version of NLog will be automatic).

NLog 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 NLog 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:
  • ReflectSoftware.Insight.dll
  • ReflectSoftware.Insight.Extensions.NLog.dll.
NLog_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="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight"/>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
  </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>
    
    <logManager>      
      <instance name="nlogInstance1" category="NLog"/>      
    </logManager>
  </insightSettings>
</configuration>
6. Now you need to configure your NLog configuration with a reference to the ReflectInsight Appender. Update your NLog section with the following:

<configuration>
  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!--
    In order to recieve location information, you must ensure the layout has the parameter ${callsite} and all its properties set accordantly.
     -->
    <extensions>
      <add assembly="ReflectSoftware.Insight.Extensions.NLog"/>
    </extensions>
    <targets>
      <target name="ReflectInsight"
              xsi:type="ReflectInsight"
              instanceName="nlogInstance1"
              displayLevel="true"
              displayLocation="true"
              layout="${callsite:className=true:fileName=true:includeSourcePath=true:methodName=true}" />
    </targets>
    <rules>
      <logger name="*" minlevel="TRACE" writeTo="ReflectInsight" />
    </rules>
  </nlog>
</configuration>
7. Alternatively you can look at the configuration files that are part of the sample application.

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

NuGet Package

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

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

sshot-303.png

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