The thing that gets me every time I see a file VS database conversation is that people seem to forget that databases store data in files. Technically, a database is nothing more than an application which provides structured access, statistics about, and easy ways to replicate, data that’s in files.
You can’t really compare database engines in general, to basic file system functions. Technically the database engines are going to be using those same file system functions anyways. You can compare database engines, to other applications designed to store and retrieve data from files though.
Where database engines shine is reading. They do so because the engine maintains indexes about where certain types of data are currently kept in files. Whereas basic file system functions don’t really track what’s in the files as much as they do track the files themselves.
These indexes however, put database engines behind basic file system functions by themselves when it comes to writing. While the file system functions can just seek to the file, determine where to start writing, and write, the database engine typically has to update the indexes as well which means looking at the data and determining where to put it along with what indexes need to be altered/recalculated/etc.
To get a picture of how this works, imagine you have someone standing in the back of a moving truck taking boxes from you and placing them in the back of the truck.
Basic filesystem functions would take the box, find somewhere in the back of the truck the box would fit without wasting a bunch of space, and be ready for another box immediately after putting it in that spot.
A database engine on the other hand, would look in the back of the truck, then look in the box, then look a categorized list of things that have already been put in the back of the truck, determine if there are enough of a certain type of item already in the truck to trigger lunch time, update the list of items, recalculate the statistics about everything in the back of the truck, and a few other odds and ends before being ready for another box.
This is why you typically don’t see things like server access logs using a database. You might see something that takes previous logs and indexes them using a database engine, but not so much something that logs directly to a database engine.
Imagine that same moving truck, but now imagine there are a dozen people bringing boxes all at the same time instead of just you.