我想在Bunyan尝试Log Rotate
这是我的剧本
var mongoClient = require('mongodb'),
bunyan = require('bunyan');
var log = bunyan.createLogger({
name: 'myapp',
streams: [
{
level:'debug',
stream: process.stdout
},
{
level: 'info',
path: 'log/log.log',
period: '1d', // daily rotation
count: 3 // keep 3 back copies
},
{
level: 'error',
path: 'log/myapp-error.log'
}
]
});
function mockFunction() {
log.info("----");
log.info("--log--");
log.info("----");
setTimeout(mockFunction, 1000);
}
mockFunction();
我如何设置每1分钟旋转一次?用于测试
我可以选择小时,日,年,月...... https://github.com/trentm/node-bunyan#stream-type-rotating-file
我也试过period: '5ms',
,但我的文件继续长大
答案 0 :(得分:2)
您必须添加type: 'rotating-file'
....{
type: 'rotating-file',
level: 'info',
path: 'log/log.log',
period: '60000ms',
count: 3
}.....