javascript - How can I pass a filename to wiston logger constructor? -
log.js:
var winston = require('winston'); var logger = new (winston.logger)({ transports: [ new (winston.transports.console)({ json: false, timestamp: true }), new winston.transports.file({ filename: **get outside**, json: false }) ], }); module.exports = logger;
a.js, want log own logfile
var logger = require('./log')('log_to_this_file'); <=== how can pass filename in? logger.info('log file');
b.js, want log own logfile
var logger = require('./log')('log_to_another_file'); <=== how can pass filename in? logger.info('log file');
i dont know how write log.js filename outside.
how can that?
can't add new logger in b.js?
var winston = require('winston'); // // configure logger `category1` // winston.loggers.add('category1', { console: { level: 'silly', colorize: 'true', label: 'category one' }, file: { filename: '/path/to/some/file' } });
Comments
Post a Comment