Is there a way to log every request in the console with restify?

Viewed 17765

I'm using restify to build an API, and I'm used to express. Is there a way to have restify log every request in the console, like express does with app.use(express.logger('dev'))?

6 Answers

There is a quick way to do it very quickly if you just want to have it for your development environment.

/**
 * Log requests.
 */
server.on('after', function(req, res, route, error) {
    console.log("------------------------")
    console.log(req.route.path)
    console.log(req.body)
});
Related