Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loggly with winston set tags dynamically

I'm using loggly with node js. This is the initialization script:

var winston  = require('winston');
require('winston-loggly-bulk');

winston.add(winston.transports.Loggly, {
    inputToken: "TOKEN",
    subdomain: "SUBDOMAIN",
    tags: ["Winston-NodeJS"],
    json:true
});

It looks like the tags are set on winston.add initialization, but what if I want to set some tag dynamically when I send a message to the logger?

like image 901
Mister_L Avatar asked Sep 13 '16 20:09

Mister_L


1 Answers

According to the winston-loggly-bulk source, it is possible to include tags in the metadata of the logging instruction using the tags property. For example:

logger.log('info', 'Server starting up.', { tags: 'server' });

The value can be either a single tag or an array, like this:

logger.log('info', 'Server starting up.', { tags: ['server', 'startup'] });
like image 128
ladenedge Avatar answered Oct 01 '22 03:10

ladenedge