I’m designing an API and have reached the topic of logging. I’m going to store my logs in Elasticsearch.
I’m certainly going to do some logging at the time the HTTP response is sent back to the client, with info such as processing time, response code, user id, URL.
Is it best practice to also send a record to the logging system right when the HTTP request enters the API server?
What I have in mind here are situations when the response never materializes, e.g. because the server dies, or takes forever processing the request (e.g. due to bad business logic). If this occurred, I’d have no record at all of the client making a request.