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

Node.js Node.js

Last Updated: Apr. 07, 2023

This document includes cluster dependent URL’s. Each URL has a variable part (in Italic). Please match this part with a row entry within the following table. Copy the table row entry located under the column that matches the top level domain of your Coralogix account (.com, .in etc.). Replace the variable part of the URL with this entry.

Coralogix DomainElasticsearch-APISSL CertificatesCluster URL
.comhttps://coralogix-esapi.coralogix.com:9443https://coralogix-public.s3-eu-west-1.amazonaws.com/certificate/Coralogix-EU.crtcoralogix.com
.ushttps://esapi.coralogix.us:9443https://www.amazontrust.com/repository/AmazonRootCA1.pemcoralogix.us
.inhttps://es-api.app.coralogix.in:9443https://coralogix-public.s3-eu-west-1.amazonaws.com/certificate/Coralogix-IN.pemapp.coralogix.in
.eu2.https://es-api.eu2.coralogix.com:9443https://www.amazontrust.com/repository/AmazonRootCA1.pemeu2.coralogix.com
sg.comhttps://es-api.coralogixsg.com:9443https://www.amazontrust.com/repository/AmazonRootCA1.pemcoralogixsg.com
npm install --save coralogix-logger

Usage:

You must provide the following four variables when creating a Coralogix logger instance.

Company ID – A unique ID that represents your company. The private key can be found under ‘settings’->’ send your logs’. It is located in the upper right corner.

Private Key – Your Coralogix private key

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.

If your Coralogix account top level domain is not ‘.com’ add the following environment variable, CORALOGIX_URL=https://api.Cluster URL/api/v1/logs

Import Coralogix’s package and send logs in a stateless fashion.
Note that the privateKey, severity, applicationName, subsystemName and text properties are mandatory.

Nodejs implementation example:

var Coralogix = require("coralogix-logger");
     
    // global confing for application name, private key, subsystem name 
    const config = new Coralogix.LoggerConfig({
        applicationName:"node tester",
        privateKey:"your-private-key",
        subsystemName:"node tester sub",
    });
     
    Coralogix.CoralogixLogger.configure(config);
     
    // create a new logger with category 
    const logger = new Coralogix.CoralogixLogger("My Category");
     
    // create a log 
    const log = new Coralogix.Log({
        severity:Coralogix.Severity.info,
        className:"className",
        methodName:"methodName",
        text:"log data"
    })
    // send log to coralogix 
    logger.addLog(log);

You can also see a working example here
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