Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to have a unique identifier on each Nginx log line. Is there a easy way to add this?


share|improve this question
up vote 3 down vote accepted

If you can assemble an UUID from nginx variables you can use log_format to add it to the log.

One common way to do that is to add an HTTP header with the UUID and capture it on nginx (it exposes all headers as $http_<header_name> variables) to add to the custom log format.

share|improve this answer

$connection variable contains connection identifier. It's not globally unique, I guess it will start from 0 after Nginx restart. But it should be unique between the restarts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.