Apache webserver can be configured to save access logs into database via Apache Module mod_log_config.

This module provides for flexible logging of client requests. Logs are written in a customizable format, and may be written directly to a file, or to an external program. Conditional logging is provided so that individual requests may be included or excluded from the logs based on characteristics of the request.

“LogFormat” directive specifies the format of the access log file.



This example save into database: IP, date, http status, sent bytes, content type, requested url, user agent, referer;

Mysql table:


Save Apache log in MySQL database
Tagged on:                         

3 thoughts on “Save Apache log in MySQL database

  • September 28, 2020 at 19:11

    This looks like this invokes the mysql client for _each_ log entry (as opposed to the old mod_log_sql_mysql which, I’m assuming, had a single, open connection to the MySQL engine to avoid invocation of the mysql binary and authentication of username/password over and over). Do you have any observations about the extra load this places on the server? I’m wondering if it would be advantageous to make a daemon that just monitored a unix socket or a pipe and sent anything written to it to the DB. That way, Apache could just write log entries to the filesystem pipe.

    • September 28, 2020 at 19:19

      You could save apache logs into Mysql database, only if you need to process in some way all the requests. Or you can choose a faster db engine for writing stuff.


Leave a Reply to kurumsal bakım anlaşması Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.