Skip to main content
All CollectionsSend your logs
Coralogix Node.js integration
Coralogix Node.js integration

Integrate your Node.js logs with our Node SDK

Yoni Farin avatar
Written by Yoni Farin
Updated over a week ago

Installation

npm install --save coralogix-logger

Usage:

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

Company ID – A private key which is used to validate your authenticity, this key will be sent to your mail once you register to Coralogix and should not be transferred outside your company.

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.

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:"75489423-f6f6-f683-017e-c77a6ba47cc2",
        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"
    })
    // semd log to coralogix
    logger.addLog(log);
Did this answer your question?