Skip to main content
All CollectionsSend your logs
Coralogix Nodejs Bunyan integration
Coralogix Nodejs Bunyan integration

Integrate your Node.js logs using Coralogix's Bunyan appender

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

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

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"); 
Did this answer your question?