Skip to content

Instantly share code, notes, and snippets.

@mrpatrick
Created October 31, 2013 21:19
Show Gist options
  • Save mrpatrick/7257377 to your computer and use it in GitHub Desktop.
Save mrpatrick/7257377 to your computer and use it in GitHub Desktop.
Apache Piped JSON excluding 2xx and 3xx statuses
# JSON extended log format including: User-Agent, Referer, and X-Forwarded-For
LogFormat "{ \"time\":\"%t\", \"remoteIP\":\"%a\", \"host\":\"%V\", \"request\":\"%U\", \"query\":\"%q\", \"method\":\"%m\", \"status\":\"%>s\", \"userAgent\":\"%{User-agent}i\", \"referer\":\"%{Referer}i\", \"X-Forwarded-For\":\"%{X-Forwarded-For}i\" }" jsonlog
# Pipe only warnings/errors to json log file
CustomLog "|/bin/grep -E --invert-match --line-buffered 'status.?[[:punct:]].?[23]' |cat >> /var/log/httpd/errors.json" jsonlog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment