BugsRadar

NLog target

Updated 1 October 2026 · BugsRadar team

The BugsRadar.NLog package adds a target: events at Error and above go to your channels with their message template and properties. It brings BugsRadar with it, so the ILogger provider and direct calls are there too.

You need a BugsRadar project with a channel and the project's API key first: see Get started. The key is secret: where it may go.

Install

Terminal
dotnet add package BugsRadar.NLog

NLog.config

Register the target's assembly and send errors to it:

NLog.config
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <extensions>
    <add assembly="BugsRadar.NLog" />
  </extensions>
  <targets>
    <target xsi:type="BugsRadar" name="bugsradar"
            apiKey="${environment:BUGSRADAR_KEY}" environment="Production" />
  </targets>
  <rules>
    <logger name="*" minlevel="Error" writeTo="bugsradar" />
  </rules>
</nlog>

apiKey and environment are NLog layouts: ${environment:...} reads an environment variable, ${configsetting:...} reads appsettings.json through NLog.Extensions.Logging.

The same setup in code

Program.cs
using BugsRadar.Extensions.NLog;
using NLog;

LogManager.Setup()
    .SetupExtensions(s => s.RegisterTarget<BugsRadarTarget>("BugsRadar"))
    .LoadConfiguration(c => c.ForLogger().FilterMinLevel(LogLevel.Error)
        .WriteTo(new BugsRadarTarget { ApiKey = "<your project API key>" }));

With the host's logger

When NLog is the host's logger through NLog.Extensions.Logging or NLog.Web.AspNetCore and the client is registered with AddBugsRadar, leave apiKey out: the target takes that client, and an error that both ILogger and NLog see is sent once.

Levels, grouping and diagnostics

The target takes Error and above; minimumLevel="Warn" on the target lowers its own floor. logger.Error(ex, "Order {OrderId} failed", 42) arrives with the template Order {OrderId} failed; a text without parameters is grouped with numbers, ids and quoted values masked. LogManager.Shutdown() drains the queue, and delivery problems of the target's own client go to NLog's internal log (internalLogLevel="Warn").

What the message looks like in the chat, how repeats are counted and when errors are bundled: see What you receive.

Next: log4net appender →