Apache Log POST Data To A Log File

last updated in Categories , , , ,

Q. How do I log POST data submitted by our user registration form to a log file under Debian Linux Apache 2 Web Server?

A. You can use mod_security or mod_dumpio module under Apache web server to dump POST data.


Apache mod_dumpio Module

This module allows for the logging of all input received by Apache and/or all output sent by Apache to be logged / dumped to the error.log file.

WARNING! These examples requires apache version 2.1.3 or above along with mod_dumpio

Step # 1: Enable mod_dumpio module

Type the following command as the root user:
$ sudo a2enmod dump_io
# a2enmod dump_io
Restart Apache Web server:
# /etc/init.d/apache2 force-reload

Step # 2: Configuration

Open httpd.conf or apache2.conf file:
# vi apache2.conf
Enable dumping of all input data:
DumpIOInput On
Enable dumping of all output at a specific LogLevel level such as notice or debug:
DumpIOLogLevel debug
If you want to enable dumping of all output, enter:
DumpIOOutput On
Save and close the file. Just restart Apache2:
# /etc/init.d/apache2 restart

How do I view logs?

All data is logged to error log file,
# tail -f /var/log/apache2/error.log
# egrep -iw 'one|two' /var/log/apache2/error.log

Further readings:


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

9 comment

  1. Apache website or search any rpm / debian repo for a package. It is part of many distro.

  2. Thankyou for the information. I would be very greatful if you could help me. My problem is
    ‘ i want to configure my apache server to get the response time of the server. for that which file should i edit? HOW????

  3. An alternative to mod_dumpio would be mod_log_post, also doing a well job for me. It works with any Apache 2.x version, thus not dependent on Apache 2.1.3 or later.

  4. I’ve enabled this but I’ve setup custom error logs for all my websites. I’ve looked in both the access and error logs and the dumping of post variables is nowhere to be seen.

  5. Hello Max,

    I am trying to log POST request data into log files. I am working on Windows XP. Can you tell me if mod_log_post is available for windows?

    Thanks for your help.

    – Sachin Jain

  6. If somebody really helps me, I could imagine to build and maintain my mod_log_post module for Windows systems. So if you’ve too much free time and real build experience with Windows systems and especially Apache modules, simply contact the mod_log_post upstream.

    Still, have a question? Get help on our forum!