4 ms·
I'd strongly favor using a DB for this (and many other) purpose(s) but the more important consideration is scalability and separation of concerns. The first ste
by DemocracyFTW2 4y ago
I'd strongly favor using a DB for this (and many other) purpose(s) but the more important consideration is scalability and separation of concerns. The first step is easiest to do with a file: just append lines as events come in. That's easy but won't scale. For one thing, that file will grow large as time goes by, so you'll need a way to deal with that, like building zip archives or similar. At any rate, none of that code should become part of your application. Your application should only call `somepackage.log( user_event )` and be entirely shielded from whether that goes into the FS or a DB, how to deal with growing need for disk space &c. Once you have that separation clear, the decision whether or not to use a DB should ideally become an implementation detail that can be changed later.
Do you plan on providing a search functionality for logs? If you don't want to search, then why do you keep that data at all? You probably do want to search, so probably you do want a DB. Doing search over flat-file data is rather limited in functionality (although it can be very valuable at times); more advanced search means that if you're doing it against flat files, you will have to reconstruct a very crappy DB engine with bugs and limitations.