C# SDK

Integrate your C# logs with Coralogix's SDK

Zvika Kozniak avatar
Written by Zvika Kozniak
Updated over a week ago

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

PM> Install-Package Coralogix.SDK

General :

Private Key – A unique ID which represents your company, this Id will be sent to your mail once you register to Coralogix.

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 enter 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.

To get an instance of the CoralogixSDK you need to provide the logger with a name. By default, this name will be used as the logging category

   CoralogixSDK.CoralogixLogger coralogixLogger;
            coralogixLogger = CoralogixSDK.CoralogixLogger.GetLogger("Cat 1");
            coralogixLogger.Configure("11111111-1111-1111-1111-111111111111", "MyTestApp", "BL");



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

            // Configure Coralogix SDK. You need to define it only once per process.
            coralogixLogger.Configure("11111111-1111-1111-1111-111111111111", "MyTestApp", "BL");

            //Send "Hello World!" message with severity verbose.
            coralogixLogger.Log(Severity.Verbose, "Hello world");

            // Additional options
            // Severity and message parameters are mandatory. The rest of the parameters are optional.
            coralogixLogger.Log(Severity.Warning, "Hello world", category: "My category", className: "My class", methodName: "My method");
            coralogixLogger.Log(Severity.Debug, "Hello world", category: "My category");
            coralogixLogger.Log(Severity.Info, "Hello world", category: "My category", className: "My class");
            coralogixLogger.Log(Severity.Error, "Hello world", category: "My category", className: "My class", methodName: "My method", threadId: "thread id");
            coralogixLogger.Log(Severity.Critical, "Hello world", category: "My category", className: "My class", methodName: "My method", threadId: "thread id");

            // Using severity methods
            // Only message is mandatory. The rest of the parameters are optional.
            coralogixLogger.Debug("Hello world", category: "My category");
            coralogixLogger.Info("Hello world", category: "My category", className: "My class");
            coralogixLogger.Warning("Hello world", category: "My category", className: "My class", methodName: "My method");
            coralogixLogger.Error("Hello world", category: "My category", className: "My class", methodName: "My method", threadId: "thread id");
            coralogixLogger.Critical("Hello world", category: "My category", className: "My class", methodName: "My method", threadId: "thread id");
Did this answer your question?