Home » Projects » Httpd » Mod_log_sql » mod_log_sql


mod_log_sql is a logging module for Apache 1.3 and 2.0 which logs all requests to a database. This began a port of the Apache 1.3 version of the module by Chris Powell, and as of February 6th, 2004 Chris Powell and I have decided to switch maintainer-ship of the module over to me.
This module now compiles under Apache 1.3 and Apache 2.0 from the same source.

The 1.9x versions are to be considered beta quality, as they contain new features and some major code cleanups. If you are using Apache 1.3 it is recommended that you use mod_log_sql version 1.18. Only use the 1.9x releases if you need the new features they provide.



Apache HTTPd>=2.0.40

Change Log

Version 1.101:

This release adds more documentation of the all the log formats and also adds documentation of the tabletype DBParam for the mysql driver. Using LogSQLDBParam tabletype ARCHIVE will set the tabletype for autocreated tables to ARCHIVE (and save TONS of space too)

Segfaulting due to not loading a driver module no longer occurs and an error message is logged to the log file stating that you didn't load the driver module.

This release also adds another sub-module that will log incoming and outgoing bytes (logio) This modules is EXCLUSIVE to the mod_logio module. Meaning if you use the mod_log_sql version you must NOT load the standard apache version. Currenlty due to how logging of outgoing bytes is done in the apache core there is NO workaround for this, you either log outgoing bytes in the text access logs OR mod_log_sql.

To actually USE the new logging fields you just need to add the "i" and "o" LogSQLLogFormat options. Please note that these are lowercase instead of uppercase like they are in mod_logio.


Due to the addition of the logio two new fields are added to the log tables. If you wish to use logging if IO then you MUST alter your existing tables adding fields bytes_in and bytes out of type int unsigned.

Version 1.100:

This release adds a new "V" log format which logs the requested hostname into virtual_host instead of the ServerName. This is exclusive to "v", Only one or the other can be used.

There are several fixes in the configure system to not error out if an optional library or file is not found. And there are several fixes to the SQL generation code fixing escaping, table names, and NULL values.

Version 1.99:

This release fixes segmentation faults of apache that occured when the preserve file was used. The errors printed to the error log are also more informative. And several autoconf detection routines were fixed.

It also adds the dbi provider which works for adding SQL content to postgresql and mysql servers, but does not support the auto creation of tables in either database. The pgsql driver stub is also included, which is no where near completed.

For win32 users, the build scripts are included in the distribution now, read the changelog for the 1.98 release for more information. If anyone wishes to contribute a MSVC project file they will be welcomed.

Version 1.98:

Contains a new configuration directives to control the Preserve file, LogSQLDisablePreserve. This option completely disables the preserve file, so if the Database cannot be contacted, those records will be lost and not logged. Also the LogSQLPreserveFile is now relative, if it does not begin with a "/", to the ServerRoot and defaults to logs/mod_log_sql-preserve. It will appear with your log files now.

Also in this release is the much requested Win32 support. I have added 2 batch scripts to compile mod_log_sql for apache 1.3 and apache 2.0. You will need to edit the files to setup the include and library paths for compiling. I compiled this with the free Command line compiler provided by Microsoft, Apache 2.0.49 and 1.3.29, Mysql 4.0, and the MS SDK from Microsoft's website. I had to obtain the msvcrt.lib file from a MS VS installation to get the dlls to compile, however. If anybody can contribute a MSVC 6 project or nmake Makefiles I would greatly appreciate it.


Unfortunately due to the license that the free compiler from Microsoft has I can not distribute binaries for Win32.

Version 1.97:

This release has several changes so be sure to read the documentation and Changelog. Changes are a new LogSQLLoginInfo syntax which better allows configuring mod_log_sql with multiple databases.. basic example.


Also the mysql code is not in a separate module that must be loaded after the core, so you will NEED to add this to your httpd.conf file.

LoadModule log_sql_mysql_module modules/
Version 1.9.6:

This release offers a new configuration directive to configure Database configuration options. LogSQLDBParam should be used over LogSQLTcpPort, LogSQLDatabase, and LogSQLSocketFile. as they are deprecated, and will most likely be removed in future versions.


Version 1.101 is the latest version available Historic version 1.18 (Last stable release for Apache 1.3 only) Repositories

Mailing Lists

There are two mailing lists for mod_log_sql. The first is the generic announcement mailing list which provides announcements for all software releases on, but can be filtered by choosing topics in the mailing list options page. The second is the user mailing list specific to mod_log_sql only. Release announcements will be cross posted to both lists.

Note: E-mails come from the domain for all mailing lists. If your e-mail gateway has a challenge/response systems configured, you will need to add an exemption for this domain in order to subscribe.

Unofficial Binaries


Thanks to Thomas Goirand, Debian users can add the following repository to their /etc/apt/sources.list if using stable branch of Debian (mod_log_sql 1.18 only):

deb stable main

This repository also includes the following packages: dtc, qmail, ucspi-tcp,mysqmail and checklocalpasswd.

The packages can also be downloaded separately for version 1.18 and 1.9x on the GPLHost website.

NOTE: Please direct any issues with these binary releases to Thomas Goirand (links on the his website), or to the mod_log_sql mailing list.


There are no win32 binaries provided by anyone at this time. If you wish to build them there is a build.bat provided in the source distribution to build with MySQL and Apache 1.3.x and Apache 2.0.x. However, remember that win32 is an unsupported platform for running mod_log_sql.

Contact & Help

E-Mail me, Edward Rudd, about mod_log_sql.

Send an e-mail to the mod_log_sql mailing list.

Bugs should be reported to the Bug Tracker.

OSI Certified