We have some services (consider 10, some of them already exist and some are yet to come). All of these services have a common part where they keep track of what's being changed, and these so-called "logs" are shown to users, and the persisting/searching pattern is also common in between all of them (searching might be different in some few parameters). So each service has 2 separate tables, namely log_action
and log_details
. The first one keeps the higher-level action that happened, and the latter one keeps the details (1-n relationship), consider the following:
User <USERNAME> changed <BIGGER_ENTITY_NAME>'s <FIELD_NAME> on <DATE_TIME>(stored in log_action):
- Changed the <FIELD_NAME> of item <ACTUAL_ENTITY> from <FROM>$ to <TO>$. (stored in log_details)
- Changed the <FIELD_NAME> of item <ACTUAL_ENTITY> from <FROM>$ to <TO>$. (stored in log_details)
... (stored in log_details)
I have 2 approaches in mind:
Creating a dedicated log service (using a NoSQL to achieve flexibility)(with the appropriate SDK for client usages):
- (+) This approach reduces boilerplate code and tables
- (+) Takes less time-effort, specially helpful for our new service developments
- (?) It probably can be considered as a whole service, it manages some resources called "logs"
- (-) Yet it's keeping some data which is basically owned by other services
Let each service manage their own logs (almost all of these services use RDBMS):
- (+) Actions are private to the service
- (-) Takes more effort developing new services
Now my question is, what is the best practice here and why? Should we consider a separate logging service? Or let each service do this on their own? Or anything else maybe?