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 Winston Node.js Winston

Last Updated: Jul. 14, 2022

To learn how more about how to get started working with Winston, check out this guide we put together.

Usage:

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. Please Replace the “Cluster URL” in the “usage example” with the URL that matches the domain of your Coralogix account (.com, .in etc.).

ClusterURL
.comapi.coralogix.com
.usapi.coralogix.us
.inapi.app.coralogix.in
.eu2.api.app.eu2.coralogix.com
sg.comapi.coralogixsg.com

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

Private Key – 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.

Application Name – The name of your environment, for example, a company named “SuperData” would probably insert the “SuperData” string parameter or if they want to debug their test environment they might insert the “SuperData– Test”.

SubSystem Name – Your application probably has multiple components, for example: Backend servers, Middleware, Frontend servers etc. in order to help you examine the data you need, inserting the subsystem parameter is vital.

For more information on how to setup and use Winston head over to our guide as well as the Winston repository.

Winston usage example:

const os = require("os");
const winston = require("winston");


const logger = winston.createLogger({
    transports: [
        new winston.transports.Http({
            name: "coralogix",
            level: "info",
            format: winston.format((info) => ({
                applicationName: "nodejs",
                subsystemName: "winston",
                computerName: os.hostname(),
                timestamp: Date.now(),
                severity: {
                    silly: 1,
                    debug: 1,
                    verbose: 2,
                    info: 3,
                    warn: 4,
                    error: 5,
                    critical: 6
                }[info.level] || 3,
                text: info.message,
            }))(),
            host: "<CLUSTER_URL>",
            path: "/logs/rest/singles",
            headers: {
                "private_key": "<YOUR_PRIVATE_KEY>"
            },
            ssl: true,
            batchInterval: 1000,
            handleExceptions: true
        })
    ],
    exitOnError: false
});

logger.info("My info log line");

Need help? We love to assist our customers, simply reach out via the in-app chat. For more information about getting started with Coralogix, schedule a meeting with one of our experts.

On this page