nginx log formats

casual nginx

a few proposed nginx log formats

log_format combined '$remote_addr - $remote_user [$time_local] '
        '"$request" $status $body_bytes_sent '
        '"$http_referer" "$http_user_agent"';

log_format main  '$remote_addr - $remote_user [$time_local] "$request" '
         '$status $body_bytes_sent "$http_referer" '
         '"$http_user_agent" "$http_x_forwarded_for"';

log_format notes '$remote_addr "$request" $status';

    log_format compression '$remote_addr - $remote_user [$time_local] '
                               '"$request" $status $body_bytes_sent '
                               '"$http_referer" "$http_user_agent" "$gzip_ratio"';

log_format sslparams '$ssl_protocol $ssl_cipher '
             '$remote_addr "$http_user_agent"';

the ideal shit

the ideal shit we would want is main + sslparams + compression

log_format mainssl '$ssl_protocol $ssl_cipher '
           '$remote_addr - $remote_user [$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"';

resources

https://nginx.com/blog/sampling-requests-with-nginx-conditional-logging/

https://serverfault.com/questions/916653/what-is-the-default-log-format-on-nginx/

https://web.archive.org/web/20230322101706/https://vikborges.com/articles/how-to-make-nginx-access-logs-more-readable-with-json/ ==> this is a big win


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2023 Pierre-Philipp Braun