简体   繁体   中英

logging in node.js using debug library

I'm currently using debug library .

Is there a way I can save the output texts from debug library to a file for log like Winston.

For example... pseudo code...

var debug = require('debug')('test');
// debug.bind('test.log'); // <-- something like this..
debug('hello world');

So.. 'hello world' should be in a test.log

I found this site where the author uses Winston.

var winston = require('winston');
//log your output to a file also
winston.add(winston.transports.File, { filename: 'somefile.log' });
//log some outputs
winston.log('info', 'Hello distributed log files!');
winston.error('Who let the dogs out?!');

Source: http://devgigs.blogspot.kr/2014/01/mastering-nodejs-logging.html?m=1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM