Loggly

Johan Dewe edited this page Jan 21, 2015 · 10 revisions

Sends logging events to Loggly using the node-loggly module.

Options:

  • token - Loggly customer token - https://www.loggly.com/docs/api-sending-data/ ,
  • subdomain - Loggly customer subdomain (use abc for abc.loggly.com),
  • tags - an array of strings to help segment your data & narrow down search results in Loggly
  • json- enable JSON logging by setting 'json: true'

Example configuration:

{ "appenders": [
    {
      type      : "loggly",
      token     : "12345678-1234-1234-1234-123456789abc",
      subdomain : "abc",
      tags      : ["test"],
      category  : "cheese",
      json      : true
    }
] }

By default this appender doesn't use one of the layouts, because they are intended to format a line for human reading. Loggly indexes the values (of all properties of objects) and makes them available for querying.

##Usage

var log4js = require('log4js');

log4js.configure({
  'appenders': [
    {
      type      : 'console',
      category  : 'test'
    },
    {
      type      : 'loggly',
      token     : '12345678-1234-1234-1234-123456789abc',
      subdomain : 'abc',
      tags      : ['test'],
      category  : 'cheese'
    }
  ]
});

var logger = log4js.getLogger('cheese');

//Generates 1 log line in Loggly
logger.info('test log string');
logger.debug({foo: 'this', bar: 'that'});

 //Generates 4 log lines in Loggly
logger.error(1, 'two', true, false);

//Generates 2 log lines in Loggly
logger.info(new Error('This should promote level to ERROR'), 'the other thing');