README
log4js-sumologic-appender
A simple log4js appender for SumoLogic with graphite metrics support.
Install
Install with npm
or yarn
:
$ npm install --save log4js-sumologic-appender
$ yarn add log4js-sumologic-appender
Example use
const log4js = require('log4js');
log4js.configure({
appenders: {
sumologic: {
type: 'log4js-sumologic-appender',
endpoint: 'http://sumo/endpoint/here',
// See config options here: https://github.com/SumoLogic/js-sumo-logger#configuration
}
},
categories: {
default: {
appenders: ['sumologic'],
level: 'trace'
}
}
});
const logger = log4js.getLogger('My App Name'); // name your logger
logger.trace('trace', 'extra', 'lines', {"json": "object here"});
logger.debug('debug', 'extra', 'lines', {"json": "object here"});
logger.info('info', 'extra', 'lines', {"json": "object here"});
logger.warn('warn', 'extra', 'lines', {"json": "object here"});
logger.error('error', 'extra', 'lines', {"json": "object here"});
logger.fatal('fatal', 'extra', 'lines', {"json": "object here"});
See example for a working example.
Error handling
In case requests to Sumo Logic fail, appender performs up to 10 retries. To override the default value for the number of retries add a maxRetryCount
property to Sumo Logic appender config:
sumologic: {
type: 'log4js-sumologic-appender',
endpoint: 'http://sumo/endpoint/here',
maxRetryCount: 5,
...
}
If none of the retries are completed successfully, an error message will be written to stderr.