[英]Logger is not a function error in Node.js
As in my previous questions I said, I am trying to create an HTTP server, testing some middlewares codes, but in my code right now is giving basically the same error from another times, but I can't see where I am getting this wrong. 就像我之前的问题一样,我正在尝试创建一个HTTP服务器,测试一些中间件代码,但是在我的代码中,从另一次出现的错误基本上是相同的,但是我看不到哪里出错了。
My code : 我的代码:
logger.js logger.js
var http = require('http');
var connect = require('connect');
var app = connect();
// setup logger middleware
app.use(connect.logger());
// actually respond
app.use(function(req, res) {
res.end('Hello World!');
});
http.createServer(app).listen(8080);
He points out to the connect.logger()
even if I am using app.use()
, still gives me this error. 即使我正在使用app.use()
,他也指出connect.logger()
app.use()
,但仍然给我这个错误。
connect.logger is not a function connect.logger不是功能
Connect no longer comes with a built-in logger! Connect不再附带内置记录器! Try using some logging library like morgan 尝试使用一些日志库,例如morgan
var http = require('http');
var connect = require('connect');
var logger = require('morgan');
var app = connect();
// setup logger middleware
app.use(logger("combined")); //Without one string in logger() it will give deprecated morgan format, so it needs to use some string for work, the documentation it say so.
// actually respond
app.use(function(req, res) {
res.end('Hello World!');
});
http.createServer(app).listen(8080)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.