Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Thanks!

share|improve this question

2 Answers 2

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

 
discard

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.