log4json

node v14.20.1
version: 1.2.1
endpointsharetweet
const { addLayout, configure, getLogger } = require('log4js'); const log4json = require('log4json');
addLayout('log4json', log4json);
configure({ appenders: { log4json: { type: 'console', layout: { type: 'log4json', separator: ' | ', space: 2, omitDefaultCategory: false, props: { ts: '@timestamp', level: 'lvl', category: 'cat', // default category will be omitted unless "omitDefaultCategory" is false stack: 'error', // only available when an error object is being logged message: 'context', callStack: 'stack', // only available when "enableCallStack" is true } } } }, categories: { default: { appenders: ['log4json'], level: 'all', enableCallStack: true } } });
const logger = getLogger('fancy-category');
logger.debug('string logs', 'another string log', {customProp: ['also listed', true]}, 'yet another string');
Loading…

no comments

    sign in to comment