Node.js
This document includes cluster-dependent URLs. Each URL has a variable part (in Italics). Match this part with a row entry within the table below. 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.
Installation
Usage
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-hand corner.
Private Key – Your Coralogix Send-Your-Data API 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://ingress./api/v1/logs"
Choose the https://ingress./api/v1/logs endpoint that corresponds to your Coralogix domain using the domain selector at the top of the page.
Getting started
Import Coralogix NPM package and follow the snippet to ship logs effortlessly. Note that the privateKey, severity, applicationName, subsystemName and text properties are mandatory.
Node.js implementation example:
// set the CORALOGIX_URL environment variable if your team URL different than <team>.coralogix.com
// process.env.CORALOGIX_URL = 'https://ingress./api/v1/logs';
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);
Additional resources
| Coralogix Endpoints | Coralogix Endpoints |
Support
Need help?
Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.
Feel free to reach out to us via our in-app chat or by sending us an email at support@coralogix.com.