Learn more about Streama© – the foundational technology behind our stateful streaming data platform. Learn More

Node.js Bunyan

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

 .com.us.in
Elasticsearch-APIhttps://coralogix-esapi.coralogix.com:9443https://esapi.coralogix.us:9443https://es-api.app.coralogix.in:9443
SSL Certificateshttps://coralogix-public.s3-eu-west-1.amazonaws.com/certificate/Coralogix-EU.crthttps://www.amazontrust.com/repository/AmazonRootCA1.pemhttps://coralogix-public.s3-eu-west-1.amazonaws.com/certificate/Coralogix-IN
.pem
coralogix.comcoralogix.usapp.coralogix.in

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 left corner.

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 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 subsystems, for example: Backend servers, Middleware, Frontend servers etc. in order to help you examine the data you need, inserting the subsystem parameter is vital.

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

For more information on how to setup and use bunyan head over to the bunyan repository.

npm install –save coralogix-logger-bunyan

Bunyan usage example:

var bunyan = require("bunyan");
    var CoralogixBunyan = require("coralogix-logger-bunyan");
     
    // global configuration for coralogix 
    var config = {
        privateKey: "your-private-key",
        applicationName: "YOUR APP NAME",
        subsystemName: "YOUR SUBSYSTEM",
    };
     
    CoralogixBunyan.CoralogixStream.configure(config);
     
    // configure bunyan to user coralogix stram 
    var logger = bunyan.createLogger({
        name: 'BUNYAN_ROOT',
        streams: [
            {
                level: 'info',
                stream: new CoralogixBunyan.CoralogixStream({category:"YOUR CATEGORY"}),
                type: 'raw'
            }
        ]
    });
     
    // use bunyan 
    logger.info('hello bunyan');
    // use bunyan child loggers and assign category to them 
    var childLogger = logger.child({category:"CHILD CATEGORY"});
    childLogger.error("Child logger bunyan"); 

Need help? We love to assist our customers, simply book your implementation session, and we will walk you through, step by step.