Where should I keep my log files?

We keep most of our logs in a separate database table. We've created our own log4j and log4net apps, have a fixed log schema with lots of nice columns and are happy with it.

Is this "best practice" (for smaller sites than Facebook, where a simple DB table just doesn't scale)?

+2


source to share


3 answers


Assuming you are using a Linux based web server, write your logs to a simple log file and run a bzip cron job every day. You can bzcat file to get its contents. The same cron script could delete files older than a given threshold, or you could delete old logs manually. This is a fairly acceptable scheme that most daemons use directly or indirectly via syslog.



Be sure to write the log file outside the public web root, or people might guess your log file names and download potentially revealing data.

+1


source


Database logs are not compressed or moved to different fields. On the other hand, looking up logs in a database probably has an advantage.



Are you worried about your current decision? If you have no problem with that, I wouldn't bother.

0


source


Why are you using a database? Do you often make complex inquiries on it? Or should the queries you use be translated into a simple search grep

?

This is the main question you should ask yourself when choosing between a plain text log file and a DB table.

0


source







All Articles