I am testing nginx and want to output variables to the log files. How can I do that and which log file will it go (access or error).
Nginx – How to Output Variable in Log for Debugging
nginx
Related Topic
- Nginx – need Nginx and something like Gunicorn
- NGINX Reverse Proxy – URL Rewrite
- Nginx – Logwatch configured for nginx with custom log format gives empty output
- Nginx – How to Use Environment Variables in Nginx.conf
- Nginx – Log Complete Request/Response with All Headers
- Nginx error log log_format variables
- Nginx error log won’t read variable
Best Answer
You can send nginx variable values via headers. Handy for development.
and you'll see in your browser's response headers:
I sometimes do this during local development.
It's also handy for telling you if a subsection is getting executed or not. Just sprinkle it inside your clauses to see if they're getting used.
So visiting a url like http://www.example.com/index.php will trigger the latter header while visiting http://www.example.com/img/my-ducky.png will trigger the former header.