Apache Logging into MySQL
On a huge demand of our merchants, I have finished the advanced logging features of Tradebit today. The problem with logging in our case is, that we have serveral thousand merchants hosting files they offer for free and they sell. The statistics for the files on sale is simple, because we can count that with the sales entries. But for the free files, we can NOT dig through serveral text files on different cluster nodes.
The solution: Apache logs with MySQL!
In order to do that, you must follow these steps (on Linux):
- install the module for Apache, if not already done
- create a central database with the appropriate table (you can switch on “auto” in the module config, which does that for you)
- add the lines for logging in your apache httpd.confs
My setup looks like this:
[root@w1 root]# ll /etc/httpd/modules/mod_log*
-rwxr-xr-x 1 root root 28969 Mar 14 2005 /etc/httpd/modules/mod_log_sql_mysql.so
-rwxr-xr-x 1 root root 62256 Mar 14 2005 /etc/httpd/modules/mod_log_sql.so
and
[root@w1 root]# grep SQL /etc/httpd/conf/httpd.conf
LogSQLTransferLogTable access_log
LogSQLTransferLogFormat AbHhMmRSsTUuv
It is important, that you test out the logging manually, before you restart the servers! Log into the database from remote like OutOfOrder shows it in the documentation!


