What datatype should I store the logs for an API request/response?
(I do not know the future, length of the string to be stored)
What datatype should I store the logs for an API request/response?
(I do not know the future, length of the string to be stored)
IMHO, a NOSQL datastore could be a good fit for this. Where you have different API calls, with different parameters, the schema-less nature of a database like MongoDB, RavenDB would be a good fit.
With regards to storing in SQL Server, a crude way would be to use NVARCHAR(MAX)
to just store a string (up to 2GB in size). This would serve OK as a pure log, but not ideal if you want to search easily on that data (monitoring/analysis purposes). You could use XML and store the data for each API call in more structured form
e.g.
<MyApiCall>
<Param1>SomeValue</Param1>
</MyApiCall>
This could then be indexed and queried a bit easier.
There is an element of "what do you want to do with the log data". I'm assuming that as you are asking from the DB point of view, that it implies you want to do some form of analysis/querying of that data (otherwise you could just log to a standard file).
Bottom line for me is a NOSQL, schemaless database would be a good fit and would be my recommendation to look into.