Skip to content

Instantly share code, notes, and snippets.

@Ferrisx4
Last active June 24, 2020 17:19
Show Gist options
  • Save Ferrisx4/eef08e632397a8288b319ec15bfdbcb4 to your computer and use it in GitHub Desktop.
Save Ferrisx4/eef08e632397a8288b319ec15bfdbcb4 to your computer and use it in GitHub Desktop.
Clean Apache Access Log format
# In httpd.conf
<IfModule log_config_module>
# Define the format
LogFormat "%{%H:%M:%S}t %>s %b \t%r" custom_ferris
# later...
# Tell Apache to write a lot somewhere and specify the format (defined earlier)
CustomLog "/private/var/log/apache2/access_log" custom_ferris
</IfModule>
@Ferrisx4
Copy link
Author

This config creates a nice Apache access log (easily readable) with the columns most likely to always be the same width on the left (timestamp, response code, size), followed by the request (including method) at the end.
Read more at the mod_log_config page.

The goal is to make it easier to read/watch by a human. The default log format includes the response code (200, 404, etc) buried within the request, which is all over the place.

Example:

13:03:03 200 661 	GET /sites/all/modules/colorbox/styles/default/colorbox_style.js?qc6k6o HTTP/1.1
13:03:03 200 2460 	GET /misc/form.js?qc6k6o HTTP/1.1
13:03:03 200 5430 	GET /misc/favicon.ico HTTP/1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment