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" ?> <configuration> <configSections> <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> </configSections> <!-- In an NLog.config file only this "nlog" section is needed as the root. App.config also needs the rest. --> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <extensions> <!--Contains GibraltarTarget class marked as "Gibraltar" target type--> <add assembly="Gibraltar.Agent.NLog2" /> </extensions> <targets> <!--Define a named target using the "Gibraltar" target type--> <target name="Gibraltar" xsi:type="Gibraltar" /> </targets> <rules> <!--Send all logging to the "Gibraltar" named target--> <logger name="*" minlevel="Trace" writeTo="Gibraltar" /> </rules> </nlog> </configuration>
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.
The latest update to PostSharp Diagnostics adds Loupe support, enabling extensive high-performance logging to be added to any .NET application with virtually no code changes. PostSharp even has a great free option for developers that complements Loupe Desktop! Read more
The first release of the Loupe Agent for .NET Core is also our first open source version of the Loupe Agent. This is the first step in our plan to open source the entire Loupe Agent to make it easier for anyone to extend and take advantage of what Loupe... Read more
Loupe Service now has a shorter, direct site name that's faster, anywhere in the world. Just to go App.OnLoupe.Com, the new CDN-accelerated endpoint for the Loupe Service. Your existing Agents and Loupe Desktops are unaffected by this change, but access to the web UI will be redirected to the new... Read more