有没有办法只记录对我的 Nodejs 服务器的每次调用。字面意思就是调用的 URL。我知道这是可能的,因为我曾经在教程中看到过一个超级快速的示例,但我不知道在哪里看到它。
这是我正在寻找的一个糟糕的例子:
app.listen(port, (call)=>{
console.log(call);
console.log(`Server running on http://localhost:${port}...`);
})
Run Code Online (Sandbox Code Playgroud)
有没有办法只记录对我的 Nodejs 服务器的每次调用?
就这样: https: //github.com/expressjs/morgan
简单的应用程序,将以 Apache 组合格式将所有请求记录到 STDOUT
var express = require('express')
var morgan = require('morgan')
var app = express()
app.use(morgan('combined'))
app.get('/', function (req, res) {
res.send('hello, world!')
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5048 次 |
| 最近记录: |