I'm running a Hapi server and I want to log each incoming request to the server.
I found this: How to log all requests made to a hapi server without using a logging library? where it says using code similar to this:
server.on('response', function (request) {
console.log(request.info.remoteAddress + ': ' + request.method.toUpperCase() + ' ' + request.url.path + ' --> ' + request.response.statusCode);
});
The problem I'm having with this solution is that it's only valid for requests after the response has occurred, while some requests won't get responded in extreme scenarios(e.g not enough CPU to process request).
Do you know how this can be achieved?