I’m working on a web service build on Slim 4, and as part of this I have tried using the middlewares/access-log and custom middleware components with the aim of recording all request-response sessions, separately from the application logs.
These work well for successful requests, however they don’t log requests that result in an error response (for example, a 404)—obviously these requests fall through to the error middleware, for which I’m using the built-in class.
My question is, is there a neat way of ensuring the middleware records the request-response session before it drops through to the error handler?