We're launching a new cybersecurity venture! Learn more about Snowbit >

.NET Core .NET Core

Last Updated: Mar. 30, 2022

Coralogix offers an easy .Net native integration in the form of an SDK.
Our SDK is open source and you can find our source code: Here

Installation:

First we need to install the SDK which is available using the Package Manager Console

#for .Net framework use this command:
Install-Package Coralogix.SDK 

#For .Net Core use this command:
Install-Package CoralogixCoreSDK

Configuration:

This code example demonstrates how to configure the logging object and send messages to it.
this example is taken from our sam project which you can review for full context: Here

using System;

namespace netcore_sdk_example
{
    using CoralogixCoreSDK;
    using System.Threading.Tasks;

    internal class Program
    {
        static void Main(string[] args)
        {
            int i = 0;

            do
            {
                CoralogixLogger coralogixLogger;

                // 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.
                coralogixLogger = CoralogixLogger.GetLogger("My class");

                // Configure Coralogix SDK. You need to define it only once per process.
                coralogixLogger.Configure("PRIVATE_KEY", "APPLICATION_NAME", "SUBSYSTEM_NAME");

                //Send "Hello World!" message with severity verbose.
                coralogixLogger.Log(Severity.Error, "Hello World Coralogix");
                i++;
                
                Task.Delay(1000).Wait();
            } while ( i < 10);
            
        }
    }
}

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

On this page