I’m designing a REST API and have reached the topic of logging. I’m going to store my logs in Elasticsearch.
Is it best practice to log both HTTP request and response, with some correlation id to match them in the logs? What are the advantages and challenges of doing it this way, as opposed to only logging requests or responses?
(I have some thoughts on this of my own: suspect it is best practice and see some advantages & challenges, but feel there’s a lack of an expert treatment of this subject online. Hoping this question will result in one.)
I’m NOT asking about whether to store in the logs the contents of every request and response. I’m asking whether to store some basic record for each request and response (e.g. timestamp, URL, IP, response code, some form of user id), or maybe just for requests, or maybe just for responses.