2014-12-03 58 views
1

我目前使用debug library使用调试库登录node.js

有没有一种方法可以将输出文本从调试库保存到Winston等日志文件中。

例如...伪代码...

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

所以..“世界你好”应在test.log中

+1

他们建议重定向像'$节点的输出app.js 2> output.txt' https://github.com/visionmedia/debug/issues/85或'$ DEBUG_FD = 3节点script.js 3> debug.log' https://github.com/visionmedia/debug/issues/146 – 2014-12-03 02:14:43

回答

2

我发现这个网站,在这里笔者采用温斯顿。

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?!'); 

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

+0

感谢您的答案..但当我更新了问题..我想记录一些使用调试图书馆不是温斯顿......有可能吗? – Anderson 2014-12-03 02:06:06

+0

啊,对不起,我误解了你的问题。 – juunas 2014-12-03 02:07:59