代码如下:问题是:1、访问日志文件没有被写入 2、这俩文件怎么把他们创建在和服务端启动文件在同一个目录下
fs = require('fs'),
accessLogfile = fs.createWriteStream('./logs/access.log', {flags: 'a'}), //访问日志
errorLogfile = fs.createWriteStream('./logs/error.log', { flags: 'a' }); //错误日志
app.configure('production', function () {
app.use(express.logger({ stream: accessLogfile }));
app.use(function (err, req, res, next) {
var now = new Date();
var time = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDate() + ' '
+ now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
var meta = '[' + time + '] '+req.method+' ' + req.url + '\r\n';
errorLogfile.write(meta + err.stack + '\r\n\r\n\r\n');
next();
});
});