Skip to content

Instantly share code, notes, and snippets.

@craigiswayne
Created May 22, 2018 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigiswayne/f65bdfb30c72156245998e5e7f1295c5 to your computer and use it in GitHub Desktop.
Save craigiswayne/f65bdfb30c72156245998e5e7f1295c5 to your computer and use it in GitHub Desktop.
Nginx Verbose Access Log Format

The snippet below outputs a verbose version of the nginx access log

To use it, simply copy the contents of verbose-access.conf and paste it into your http block.

NB:

make sure to remove / comment out any existing access_log definitions such as access_log /var/log/nginx/access.log;

Example output:

Timestamp:         22/May/2018:09:49:01 +0000

    Matched Server:     localhost
    Protocol:           HTTP/1.1
    IP (server):        172.20.0.7
    IP (remote):        172.20.0.1
    Port:               80
    Status:             200

    Request:            GET / HTTP/1.1
    Requested URI:      /
    URI:                /index.php
    Query Args:         -

    Request Body:       -
    Request Body File:  -

    Request Filename:   /var/www/html/index.php
    Realpath Root:      /var/www/html
    Final File:         /var/www/html/index.php

    ## Misc
    Remote User:        -
    Referrer            -
    User Agent          Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
    Forwarded for       -

    ## cache


    ===============================================================================
log_format verbose '
Timestamp: $time_local
Matched Server: $server_name
Protocol: $server_protocol
IP (server): $server_addr
IP (remote): $remote_addr
Port: $server_port
Status: $status
Request: $request
Requested URI: $request_uri
URI: $uri
Query Args: $args
Request Body: $request_body
Request Body File: $request_body_file
Request Filename: $request_filename
Realpath Root: $realpath_root
Final File: $realpath_root$uri
## Misc
Remote User: $remote_user
Referrer $http_referer
User Agent $http_user_agent
Forwarded for $http_x_forwarded_for
## cache
===============================================================================';
access_log html/logs/nginx/access-verbose.log verbose;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment