0

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
};
1
  • Try res.json(obj) for JSON or res.jsonp(obj) for JSONP - expressjs.com/api.html#res.json. I've also checked your code and can see entries for the /raw requests in console logs. Can you clarify what does it mean that JSON is not being logged? Commented Jan 13, 2014 at 21:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.