Nginx - Log (log_format)

About

This article is about the Web/HTTP log of nginx.

The log is:

Example of specific log format

This log format include response times.

  • Definition
log_format mtail '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent $request_time '
                 '"$http_referer" "$http_user_agent" "$content_type" "$upstream_cache_status"';
  • then the access logs format needs to be enabled in each server section:
access_log /var/log/nginx/mtail/access.log mtail;
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

Default

If the format is not specified then the predefined “combined” format is used.

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





Discover More
HTTP - Request IP Address

The users / original IP address of a request is stored in the following headers without proxy: X_REAL_IP with proxy: geolocalization of your users An HTTP reverse proxy uses non-standard headers...
Scale Counter Graph
How to get Started With FluentBit

FluentBit from Calyptia is a log collector (ie observability pipeline tool) (written in C, that works on Linux and Windows). It's the Fluentd successor with smaller memory footprint When you need...
Nginx - Diagnostic / Debug

This page adds information on how to be able to diagnostic or debug a problem with nginx Error log
Web - Log (Http log)

A Web Log is a log file that logs information over a request and response. See: the log from the Apache server the Nginx log The information that may be listed in a http server log are information...



Share this page:
Follow us:
Task Runner