I have built out most of the preliminary models I will need for my web application but am thinking that I should also make models for logs.
So my question is, what do you log in your database and what would you recommend at bare minimum I log for my web app? P.S at this time due to being so new I am not looking to sign up for external services like BugSnag or LogRocket. Thank you!
Hi,
at least you need to track all the exceptions end errors.
Everything else depends on what your SaaS does.
What data should be logged depends upon the product that you are building. Of course, logs of important events is a necessity for all decent products but apart from that what else to store is tricky.
You might not want to log EVERYTHING and put unnecessary stress on the storage. However, if you can log user activity then do it. Not just log, but also display it to the user. This might also encourage customers to signup for more logins instead of sharing one among 10 people because they get to see who did what (accountability for actions).
I'm a big fan of structured logging using any of the zillion logging services out there. The main thing I think about when deciding what to log is: if a user emails me and says I tried to do X and it didn't work, will I be able to go to my logs and reconstruct what they did and where the problem is? That means I usually need to make sure I'm doing enough logging with sufficient specificity to track each user through the app.
I treat analytics separately and use a service like segment to pipe that data to services that help with whatever type of analytics I'm trying to do. Since I'm sharing data with a third party, I try to only send them aggregate data that isn't identifiable to a particular customer.
My general approach to logging is to log anything meaningful or anything that provides visibility into the behavior of the application.. "user did X", "connection to service Y failed", etc. It's not something done upfront, but you gradually add log statements as you continue to build and improve your application, and as need arises.
If you're thinking in terms of product analytics, IMO what's most important is logging what you think shows engagement with your product. This is usually related to some primary entity in your system. Twitter is a good example, you have Tweet entities and for those entities you have Impressions (views) and Engagements (clicks).
For analytics, I would log the data, but also structure and store is separately (different DB table).