Apache Log POST Data To A Log File

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.

Advertisement

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
OR
# 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
OR
# egrep -iw 'one|two' /var/log/apache2/error.log

Further readings:

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

9 comments… add one
  • Shantanu Oak Jun 6, 2008 @ 4:45

    From where can I download the module mod_dumpio ?

  • 🛡️ Vivek Gite (Author and Admin) nixCraft Jun 6, 2008 @ 6:52

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

  • Rohith Jan 23, 2009 @ 6:31

    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????

  • Max Jul 5, 2009 @ 23:06

    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.

    • Frank Oct 4, 2016 @ 16:11

      Is there a reference to mod_log_post anywhere?

  • Ryan Blunden Jul 27, 2009 @ 3:01

    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.

  • Sachin Jain Oct 14, 2009 @ 15:45

    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.

    Regards,
    – Sachin Jain

  • Robert Oct 18, 2009 @ 15:36

    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.

  • Ivy Joy Aguila Jul 30, 2015 @ 10:34

    please note that on Apache 2.4
    “mod_dumpio: DumpIOLogLevel is no longer supported. Data is always logged at LogLevel trace7.” this is from
    http://httpd.apache.org/docs/2.4/upgrading.html
    Thanks :)

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.