2014-12-03 34 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