Using Loupe with NLog

Today’s Advent treat is how you can easily use NLog with Loupe

Loupe has a built-in logging API that’s designed to cover a wide range of user scenarios, but sometimes you want to complement that with a third-party logging system like NLog.  This may be because you already have a deep investment in NLog or perhaps it has a feature that we don’t support yet.

The good news is that Loupe comes with an NLog Target, a small class that interfaces from NLog to an external logging system (like Loupe).  We provide this target via NuGet as well as in the SDK directory when you install Loupe.  It’s available both as an assembly and as source code so you have a lot of deployment options.

Once you’ve gotten the Loupe logging target for NLog you have to configure NLog to use it.  NLog can pull its configuration from the application configuration file (e.g. app.config or web.config) or from a separate configuration file.

<?xml version="1.0" encoding="utf-8" ?>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
  <!-- In an NLog.config file only this "nlog" section is needed as the root.  App.config also needs the rest. -->
  <nlog xmlns=""
      <!--Contains GibraltarTarget class marked as "Gibraltar" target type-->
      <add assembly="Gibraltar.Agent.NLog2" />
      <!--Define a named target using the "Gibraltar" target type-->
      <target name="Gibraltar" xsi:type="Gibraltar" />
      <!--Send all logging to the "Gibraltar" named target-->
      <logger name="*" minlevel="Trace" writeTo="Gibraltar" />

And that’s it - a small change to your NLog configuration file and you’re sending information to Loupe! You can continue to use your existing logging targets in parallel without fear, which is particularly great if you’re trying out Loupe and don’t want to get in the way of your current processes.

For more information:

We really like NLog - it’s a great, open source log system.  That’s one of the reasons we’ve made sure we have great support to let you capture all of that information along with everything else the Loupe Agent already captures.  You can use it as part of a migration strategy to transition your logging to working with Loupe directly or as a long term approach to take advantage of other benefits NLog offers.

Related Posts

We're out of our Last Data Center

Back in January of 2016 we decided to completely transition out of our data centers and into the cloud (primarily Azure). We knew we had to do something - either make some big investments in new hardware or commit ourselves to migrating everything off our own gear. After looking at... Read more

Rock solid centralized .NET logging

Unlimited applications, unlimited errors, starting at $25/month