Breaking News from AWS re:Invent
Coralogix receives AWS Rising Star award!

Back to All Integrations

NLog NLog

Last Updated: Sep. 10, 2023

This tutorial demonstrates how to implement NLog with the Coralogix platform.


To install Coralogix.NLog, run the following command in the Package Manager Console.

For .NET 5+, use:

Install-Package CoralogixCoreNLog



Provide the following variables.

Private KeyYour Coralogix Send-Your-Data API key
Application NameThe name of your application, as it will appear in your Coralogix dashboard. For example, a company named SuperData might insert the SuperData string parameter. If SuperData wants to debug its test environment, it might use SuperData–Test.
Subsystem NameThe name of your subsystem, as it will appear in your Coralogix dashboard. Applications often have multiple subsystems (ie. Backend Servers, Middleware, Frontend Servers, etc.). In order to help you examine the data you need, inserting the subsystem parameter is vital.

Via XML NLog Configuration

To use XML configuration, you must set the CORALOGIX_LOG_URL environment variable to the Coralogix Bulk Logs endpoint associated with your Coralogix domain.


<?xml version="1.0" ?>
<nlog xmlns="<>"
    <add assembly="CoralogixNLog"/>
    <target name="console" xsi:type="CoralogixNLog"
            PrivateKey="<Private Key>"
            layout="${date:format=HH\\:MM\\:ss} ${logger} ${message}" />

    <logger name="*" minlevel="Info" writeTo="console" />

Via Code

using NLog;
using NLog.Config;
using NLog.Coralogix;

//Set to the ingress endpoint for your Coralogix Domain
Environment.SetEnvironmentVariable("CORALOGIX_LOG_URL", "<>");

LoggingConfiguration config = new LoggingConfiguration();

CoralogixTarget coralogixTarget = new CoralogixTarget();
config.AddTarget("Coralogix", coralogixTarget);

//Configure the Coralogix target with the Coralogix settings.
//You need to configure this only once.
coralogixTarget.PrivateKey = "<Private Key>";
coralogixTarget.ApplicationName = "DotNet";
coralogixTarget.SubsystemName = "NLog";     

coralogixTarget.Layout = @"${date:format=HH\\:mm\\:ss} ${logger} ${message}";

//Configure the Level filter for the Coralogix Target 
var rule1 = new LoggingRule("*", NLog.LogLevel.Debug, coralogixTarget);

// Define the actual NLog logger which through it all log entires should be reported
NLog.LogManager.Configuration = config;

// The common practice is to get an instance of the logger in each class and setting the logger name to the class name.
//logger name will be used as category unless specified otherwise.
NLog.Logger nlogger = NLog.LogManager.GetLogger("MyApp");

nlogger.Debug("Debug Message");
nlogger.Info("Info Message");
nlogger.Warn("Warning Message");
nlogger.Error("Error Message");
nlogger.Trace("Trace Message");




  • You can also use the CORALOGIX_LOG_URL environment variable to set your endpoint instead of doing it in code if needed.
  • To do so, set the CORALOGIX_LOG_URL environment variable to the Coralogix Bulk Logs endpoint associated with your Coralogix domain.


Need help?

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us via our in-app chat or by sending us an email at [email protected].

On this page