I would like to be able to build up a log of user activities, capturing data such as who they were, where they logged in from, what activity did they take, and what data did they change (both before and after).
Most of the user-related data can easily be picked up by middleware running on my web server, that can hook into the HTTP context for every request, and based upon some rules I define, it can publish an event to an event stream. However, while it can tell me what new values were set (based on the request body), it cannot tell me what the old data values were, at least not without integrating it down to the database layer.
Conversely, I can easily find out what old values and new values are by writing code at the database level (e.g. with triggers or CDC), and then publishing those as data events to the event stream, but that approach doesn't have access to all the user HTTP metadata.
I could potentially combine the two approaches, using a correlation identifier to match up the HTTP and the SQL events, but it doesn't feel like a decent solution. I'm trying to avoid any approach that requires the developer to have to write explicit logging code somewhere in the business layer to capture all the data.