Reputation: 2067
I wanted to keep records of the http responses my server is throwing. So, for example, for each server request, I would like to record if the http response was a 1xx response, or a 2xx, 3xx and so on. At the end of the day, I would like to see, for example, that from the 1000 requests, 2% of them are a 5xx server error responses. I’m using the laravel framework.
I don’t want to redirect the responses, nor change the response messages. I just want to keep records of them. How could I achieve that? I'm not sure in which point of the laravel model I should introduce my logic. Where to intercept the final response?
Thank you for your help! :)
Upvotes: 0
Views: 178
Reputation: 2067
It seems like I have three options.
Upvotes: 0
Reputation: 3315
You can use a global middleware "after", see this https://laravel.com/docs/5.2/middleware#defining-middleware
Then check the response
\Illuminate\Http\Response
, you have a status()
method on it that gives you the response status.200 OK
status.Upvotes: 1