Our next-gen architecture is built to help you make sense of your ever-growing data Watch a 4-min demo video!

Back to All Integrations

NLog NLog

Last Updated: Feb. 07, 2023

NLog Implementation tutorial: 

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

Install-Package Coralogix.NLog

For .NET Core, use: 

Install-Package CoralogixCoreNLog


Private Key– Your private key is a unique ID that represents your company.

Application Name – The name of your main application, for example, a company called “SuperData” would probably insert the “SuperData” string parameter or if they want to debug their test environment they might insert the “SuperData– Test”.

SubSystem Name – Your application probably has multiple subsystems, for example, Backend servers, Middleware, Frontend servers, etc. to help you examine the data you need, inserting the subsystem parameter is vital.

Via NLOG configuration XML:

<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
    <add assembly="CoralogixNLog"/>
    <target name="console" xsi:type="CoralogixNLog"
            layout="${date:format=HH\:MM\:ss} ${logger} ${message}" />

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

Via code:

LoggingConfiguration config = new LoggingConfiguration();

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

            //Configure the Croalogix target with the Coralogix settings.
            //You need to configure this only once.
            coralogixTarget.PrivateKey = "9626c7dd-8174-5015-a3fe-5572e042b6d9";
            coralogixTarget.ApplicationName = "MyTestApp";
            coralogixTarget.SubsystemName = "BL";

            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("Hello world");
            nlogger.Info("Hello world");
            nlogger.Warn("Hello world");
            nlogger.Error("Hello world");
            nlogger.Trace("Hello world");

Need help? We love to assist our customers, simply reach out via the in-app chat, and we will walk you through, step by step.

On this page