Morgan seems to be logging only HTTP requests created using routes like this:
app.get('/', function (req, res) {
res.send('hello, world!')
})
I am trying to log requests created using express.static()
. How do I do that?
Here's my full code:
const express = require('express');
var morgan = require('morgan');
const cors = require('cors');
const app = express();
const port = 3001;
app.use(cors());
app.use(express.static('public'));
app.use(morgan('tiny'))
app.listen(port, () => {
console.log(`Listening on port ${port}`)
});
Turns out that order matters. Just had to move
morgan
beforeexpress.static()
: