Is there a reason that most logs seem to be in plain text, as opposed to being put in a MySQL/other sort of database?
It seems to me that putting them into a database would make analysis much, much easier…but would that come at the sacrifice of speed or something else?
(I’m not that concerned with portability, and obviously you’d have text logs for your database connection.)
I can think of two big reasons:
First, databases are slower than text files when it comes to simply appending information to a file. With a database, you have to establish a connection, transmit data over the network, store it in an indexed structure, et cetera. With a file, you need only write out the error to local disk.
Second, sometimes the things you want to log pertain to the database being broken. If the local disk is broken, you’ve got bigger problems than trying to generate log files. But you can log database outages even when everything else is working.
Having said that, there are plenty of situations where the information I want to log is relevant only while the application is properly functioning, and when I already have a database connection. In those cases, I do log directly to MySQL.