Question

Update:

My mistake, I needed to move the app.use(express.logger('dev')); to the earlier in the program. It now logs every GET and POST.

Express server listening on port 3000
GET /raw 200 13ms
GET /data 304 17ms
GET /stylesheets/style.css 304 3ms
GET / 304 2ms
GET /stylesheets/style.css 304 2ms

I am noticing that the standard middleware express (connect) logging package does a fine job with get requests that use the Routes and Views, but I also have a get that just returns JSON. That is not being logged. Am I doing something wrong?

app.use(express.logger('dev'));
var data = {"testing": "fun"};
app.use(express.compress());
app.use(express.favicon('images/favicon.ico'));
app.use(express.json());
app.use(express.urlencoded());
app.get('/raw', rawData);

function rawData(req, res) {
    res.set({'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'});
    res.set({'Content-Type': 'application/json' });
    res.send(data); // adds content-length
};
Was it helpful?

Solution

Update:

My mistake, I needed to move the app.use(express.logger('dev')); to the earlier in the program. It now logs every GET and POST.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top