Which do you prefer and why? I am not talking about application logging, only actions users perform, say on a web application, when for example the user logs in, signs up, etc.
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, <i>none of that code should become part of your application</i>. 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.<p>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.
The format doesn't matter so much as how easily the information logged is consumable. Use whatever makes it easy for you to find information from your logs, and that depends wholly on your context, eg if you have a Siem, centralized logging, legal requirements, etc.