Node.js按照日期分割日志,第一天的日志是完整的,第二天之后的日志不完整

qq_15770051 2015-06-05 03:11:16
log4js.json文件如下:
{
"appenders": [
{
"type": "console",
"category": "console"
},
{
"type": "dateFile",
"filename": "logs/cloud",
"pattern":"_yyyy-MM-dd",
"alwaysIncludePattern": false,
"category": "[usermanage]"
},
{
"type": "dateFile",
"filename": "logs/cloud",
"pattern":"_yyyy-MM-dd",
"alwaysIncludePattern": false,
"category": "[iam_msater]"
},
{
"type": "dateFile",
"filename": "logs/cloud",
"pattern":"_yyyy-MM-dd",
"alwaysIncludePattern": false,
"category": "[devicemanage]"
},
{
"type": "dateFile",
"filename": "logs/cloud",
"pattern":"_yyyy-MM-dd",
"alwaysIncludePattern": false,
"category": "[iam_lbl]"
}
],
"levels": {
"[usermanage]": "DEBUG",
"[iam_msater]": "DEBUG",
"[devicemanage]": "DEBUG",
"[iam_lbl]": "DEBUG"
}
}
根据此配置的logtest.js文件如下,为了模拟日志产生,用了setInterval函数:
var log4js = require('log4js');
log4js.configure("./log4js.json");
var logUser = log4js.getLogger('[usermanage]');
var logIm = log4js.getLogger('[iam_msater]');
var logDev = log4js.getLogger('[devicemanage]');
var logIl = log4js.getLogger('[iam_lbl]');
var arr = [];
arr[0] = logUser;
arr[1] = logIm;
arr[2] = logDev;
arr[3] = logIl;
setInterval(function(){
for(var i=0;i<4;i++){
arr[i].debug("------"+i+"-------"+new Date());
}
},5000);
console.log("OK!");
将时间调到6.12日 23:58,执行node logtest.js,产生了一份日志cloud内容如下:
2015-06-12 23:59:30.246] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:30 GMT+0800 (中国标准时间)
[2015-06-12 23:59:35.247] [DEBUG] [usermanage] - ------0-------Fri Jun 12 2015 23:59:35 GMT+0800 (中国标准时间)
[2015-06-12 23:59:35.247] [DEBUG] [iam_msater] - ------1-------Fri Jun 12 2015 23:59:35 GMT+0800 (中国标准时间)
[2015-06-12 23:59:35.247] [DEBUG] [devicemanage] - ------2-------Fri Jun 12 2015 23:59:35 GMT+0800 (中国标准时间)
[2015-06-12 23:59:35.247] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:35 GMT+0800 (中国标准时间)
[2015-06-12 23:59:40.249] [DEBUG] [usermanage] - ------0-------Fri Jun 12 2015 23:59:40 GMT+0800 (中国标准时间)
[2015-06-12 23:59:40.249] [DEBUG] [iam_msater] - ------1-------Fri Jun 12 2015 23:59:40 GMT+0800 (中国标准时间)
[2015-06-12 23:59:40.249] [DEBUG] [devicemanage] - ------2-------Fri Jun 12 2015 23:59:40 GMT+0800 (中国标准时间)
[2015-06-12 23:59:40.249] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:40 GMT+0800 (中国标准时间)
[2015-06-12 23:59:45.251] [DEBUG] [usermanage] - ------0-------Fri Jun 12 2015 23:59:45 GMT+0800 (中国标准时间)
[2015-06-12 23:59:45.251] [DEBUG] [iam_msater] - ------1-------Fri Jun 12 2015 23:59:45 GMT+0800 (中国标准时间)
[2015-06-12 23:59:45.251] [DEBUG] [devicemanage] - ------2-------Fri Jun 12 2015 23:59:45 GMT+0800 (中国标准时间)
[2015-06-12 23:59:45.251] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:45 GMT+0800 (中国标准时间)
[2015-06-12 23:59:50.251] [DEBUG] [usermanage] - ------0-------Fri Jun 12 2015 23:59:50 GMT+0800 (中国标准时间)
[2015-06-12 23:59:50.251] [DEBUG] [iam_msater] - ------1-------Fri Jun 12 2015 23:59:50 GMT+0800 (中国标准时间)
[2015-06-12 23:59:50.251] [DEBUG] [devicemanage] - ------2-------Fri Jun 12 2015 23:59:50 GMT+0800 (中国标准时间)
[2015-06-12 23:59:50.251] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:50 GMT+0800 (中国标准时间)
[2015-06-12 23:59:55.254] [DEBUG] [usermanage] - ------0-------Fri Jun 12 2015 23:59:55 GMT+0800 (中国标准时间)
[2015-06-12 23:59:55.254] [DEBUG] [iam_msater] - ------1-------Fri Jun 12 2015 23:59:55 GMT+0800 (中国标准时间)
[2015-06-12 23:59:55.254] [DEBUG] [devicemanage] - ------2-------Fri Jun 12 2015 23:59:55 GMT+0800 (中国标准时间)
[2015-06-12 23:59:55.255] [DEBUG] [iam_lbl] - ------3-------Fri Jun 12 2015 23:59:55 GMT+0800 (中国标准时间)

当时间过了00:00之后,上一份日志名字改为cloud_2015-06-12,又产生了一份新的cloud日志,内容如下:
[2015-06-13 00:00:00.256] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:00 GMT+0800 (中国标准时间)
[2015-06-13 00:00:05.261] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:05 GMT+0800 (中国标准时间)
[2015-06-13 00:00:10.268] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:10 GMT+0800 (中国标准时间)
[2015-06-13 00:00:15.271] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:15 GMT+0800 (中国标准时间)
[2015-06-13 00:00:20.273] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:20 GMT+0800 (中国标准时间)
[2015-06-13 00:00:25.302] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:25 GMT+0800 (中国标准时间)
[2015-06-13 00:00:30.305] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:30 GMT+0800 (中国标准时间)
[2015-06-13 00:00:35.309] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:35 GMT+0800 (中国标准时间)
[2015-06-13 00:00:40.334] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:40 GMT+0800 (中国标准时间)
[2015-06-13 00:00:45.337] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:45 GMT+0800 (中国标准时间)
[2015-06-13 00:00:50.340] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:50 GMT+0800 (中国标准时间)
[2015-06-13 00:00:55.342] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:00:55 GMT+0800 (中国标准时间)
[2015-06-13 00:01:00.345] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:01:00 GMT+0800 (中国标准时间)
[2015-06-13 00:01:05.346] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:01:05 GMT+0800 (中国标准时间)
[2015-06-13 00:01:10.347] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:01:10 GMT+0800 (中国标准时间)
[2015-06-13 00:01:15.347] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:01:15 GMT+0800 (中国标准时间)
[2015-06-13 00:01:20.348] [DEBUG] [usermanage] - ------0-------Sat Jun 13 2015 00:01:20 GMT+0800 (中国标准时间)

这份日志只有usermanage日志,但是没有其余几个模块的日志。。。什么原因呢???求大神解决!!!
...全文
268 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,888

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧