Logging Plugin for Microgateway

I want to configure Bunyan logging plugin for micro gateway. Could you please help me with the steps to integrate it. I followed the steps in the below link but I am not able to see the logs in the path specified apart from the default logs.

https://apigee.com/about/blog/api-technology/tutorial-adding-logger-plugin-apigee-edge-microgateway

Could you please help me with the complete reference for integrating the Bunyan logging plugin.

Thank you.

0 4 968
4 REPLIES 4

Former Community Member
Not applicable

@srinandans

I have referred the above link as well and even it contains the same info what I have mentioned in the above link.

@Dino-at-Google could you please help me with this requirement.

We are planning to log parallel call logs to Splunk server using this plugin. could you please help me with this.

Thanks in Advance.

bhanuseri
Participant I

//Write Custom Plugin using the "Bunyan"

var bunyan = require("bunyan");

var splunkBunyan = require("splunk-bunyan-logger");

var config = { token: "your-token-here", url: "https://splunk.local:8088" };

var splunkStream = splunkBunyan.createStream(config);

// Enable SSL certificate validation

stream.logger.requestOptions.strictSSL = true;

// Note: splunkStream must be set to an element in the streams array

module.exports.init = function() {

//use either bunyan OR splunkBunyan to createLogger()

var log = bunyan.createLogger(

{ name: "my logger", streams: [

{ level: 'error', stream: splunkStream },

{ level: 'debug', stream: process.stderr, },

{ level: 'info', type: 'rotating-file', path: '/var/log/foo.log', period: '1d' <!-- daily rotation--> , count: 3 <!-- keep 3 back copies--> }

]

});

return { onrequest: function(req, res, next)

{

log.info('ONREQUEST'); next();

}, onend_request: function(req, res, data, next) { log.info("ONEND_REQUEST"); next(null, data);

}

};

}

//referrer

// https://npm.taobao.org/package/splunk-bunyan-logger

// https://www.npmjs.com/package/bunyan#streams

//Installation

//npm install --save splunk-bunyan-logger

Is there a way to force this plugin, like analytics plugin? We are using oauth and in case of error it skips logger plugin/any plugin that comes next.