I want to route some logs from my application to a database. Now, I know that this isn't exactly the ideal way to store logs, but my use case requires it.
I have also seen how one can write their own database logger as explained here,
python logging to database
This looks great, but given that a large number of logs are generated from an application, I feel like sending as many requests to the database could maybe overwhelm it? It may not be the most efficient solution?
Given that this argument is correct, what are some efficient methods for achieving this?
Some ideas that come to mind are,
- Write the logs out to a log file during application run time and develop a script that will parse the file and make bulk inserts to a database.
- Build some kind of queue architecture that the logs will be routed to, where each record will be inserted to the database in sequence.
- Develop a type of reactive program, that will run in the background and route logs to the database.
- etc.
What are some other possibilities that can be explored? Are there any best practices?