Skip to content

Logging

The access log and the application log are the two main logs. The access log has one line per request. The application log records what Imagizer did to serve each request, at a configurable level (debug, info, warn, or error; the default is info and above). Imagizer runs several other log services as well, listed under Log services.

Logs can be sent to Syslog, Datadog, or CloudWatch. To read them on the instance, turn on local logging and open http://IMAGIZER_HOST:17006/logs.

Access log

The access log records one line per request in an extended combined format.

Nginx Log Format

log_format  main  '$remote_addr - $remote_user [$time_local] '
                  '"$request" $status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for" '
                  '$host $request_time '
                  '$upstream_http_x_original_filesize $upstream_http_x_original_resolution '
                  '$upstream_http_x_origin_fetch_time $upstream_http_x_original_response_code '
                  '$upstream_http_x_imagizer_server '
                  '$imagizer_request_id';

Example Log Entry

127.0.0.1 user-identifier user [05/Aug/2021:17:44:17 +0000] "GET /image.jpg?width=200 HTTP/1.1" 200 24000 "https://example.com" "Mozilla/5.0..." "127.0.0.1, 127.0.0.2, 127.0.0.3" xxxxx.imagizer.com 0.320 988376 2000x2000 292 200 10.0.1.42 b0395187a1475b96465c0c329c308d8f

A - in a field means the value was missing.

  • 127.0.0.1 is the IP address of the client (remote host) which made the request to the server.
  • user-identifier is the RFC 1413 identity of the client. Usually "-".
  • user is the userid of the person requesting the document. Usually "-" unless .htaccess has requested authentication.
  • [05/Aug/2021:17:44:17 +0000] is the date, time, and time zone that the request was received, by default in strftime format %d/%b/%Y:%H:%M:%S %z.
  • "GET /image.jpg?width=200 HTTP/1.1" is the request line from the client. The method GET, /image.jpg?width=200 the resource requested, and HTTP/1.1 the HTTP protocol.
  • 200 is the HTTP status code returned to the client. 2xx is a successful response, 3xx a redirection, 4xx a client error, and 5xx a server error.
  • 24000 is the size of the object returned to the client, measured in bytes.
  • https://example.com is the HTTP Referrer URL.
  • "Mozilla/5.0..." is the user agent from the client.
  • "127.0.0.1, 127.0.0.2, 127.0.0.3" is the X-Forwarded-For header chain of IP addresses.
  • xxxxx.imagizer.com is the hostname of the request.
  • 0.320 is the total time spent processing the request.
  • 988376 is the file size of the origin image before processing.
  • 2000x2000 is the resolution of the origin image before processing.
  • 292 is the fetch time in milliseconds from the origin image storage.
  • 200 is the http status code from the image origin fetch.
  • 10.0.1.42 is the IP of the backend node that processed the request (the X-Imagizer-Server value). It is - for requests served from cache. In a cluster it links the access line to the application log on that node.
  • b0395187a1475b96465c0c329c308d8f is the request trace ID, shared with the application log, where it appears as rid=.

Request trace ID

Every request gets a trace ID. It appears as the last field of each access log line, and as rid=<id> on every application log line. If the request arrives with an X-Request-Id header (set by a CDN or an upstream proxy), Imagizer reuses it so the same ID stays with the request through each hop. If there is no such header, Imagizer generates one. The ID is also returned to the client in the X-Request-Id response header.

The same ID is on the access line and on every application log line for the request, including on cache hits and 404s. Searching your logs for one ID gives you the full history of a single request. In a cluster the ID also lets you line up the access and application logs even if they were written on different nodes.

Logging in a cluster

In a cluster a request first reaches a front node, which load balances it to a backend node that processes the image. That backend may be a different machine than the front, or it may be the same one. When it is a different machine, the request's two log lines are written in different places: the access line on the front node, the application line on the backend node.

         request                       load balance
 client ──────────►  front node  ──────────────────►  backend node
                     10.0.1.5                          10.0.1.42
                        │                                  │
                writes the access line          writes the application line
                  imagizer_access                 imagizer_app
                  …  10.0.1.42  <id>              …  rid=<id>
                        │                                  │
                        └──────────── same <id> ───────────┘

To pair the two lines, read the last field of the access line. That X-Imagizer-Server value (10.0.1.42 above) is the backend node that processed the request and wrote the application log. Find that node, then search its application log for the shared rid= request trace ID. X-Imagizer-Server is empty for requests served from cache, since no backend node was involved.

If one node both receives and processes the request, both lines are on that node.

Log services

  • imagizer_access The access logs in the combined format.
  • imagizer_access_err The access error log. Formatted as a standard Nginx error log.
  • imagizer_app The Imagizer application log.
  • imagizer_system The Imagizer system log.
  • imagizer_stats_collector The Imagizer stats collection log.
  • imagizer_vision The Imagizer computer vision service log (face/eye detection and red-eye).
  • nginx_varn An internal access log. Used for debugging purposes. (default: disabled)
  • nginx_varn_err An internal access error log. Used for debugging purposes. (default: disabled)
  • imagizer_admin_access The admin access logs (from port 17006) in the combined format.
  • imagizer_admin_access_err The admin access error log. Formatted as a standard Nginx error log.
  • imagizer_health The health check agent logs.
  • imagizer_health_access The access logs for /health checks. (default: disabled)

Configuration

See the logging config reference for the full list of options, including log levels, local logging, and the Syslog, Datadog, and CloudWatch destinations.