How to make a record into the logfile the contents of the HTTP request header (all) as received by apache?
Currently my apache combined log format configuration is:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" combined
I understand that it is possible to do it so:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\" \"%{heading name}i\" \"%{heading name}i\" \"%{heading name}i\"" combined
but it is not logical and it is not possible to know which headers will be.
To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.
POST data is sent in the request's body, so Apache can't log POST requests by default. You can log POST request details by using dumpio module for Apache, which allows logging of HTTP request body.
In Linux, Apache commonly writes logs to the /var/log/apache2 or /var/log/httpd directories depending on your OS and Virtual Host overrides. You can also define a LogFormat string after the filename, which will only apply the format string to this file.
HTTP does not place a predefined limit on the length of each header field or on the length of the header section as a whole, as described in Section 2.5.
mod_log_forensic is what you want, but it may not be included/available with your Apache install by default.
Here is how to use it.
LoadModule log_forensic_module /usr/lib64/httpd/modules/mod_log_forensic.so <IfModule log_forensic_module> ForensicLog ${APACHE_LOG_DIR}/forensic.log </IfModule>
Note: Your path may vary, such as /usr/lib/apache2/modules/mod_log_forensic.so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With