We show how to use the NGINX JavaScript module to capture data about requests that cause errors, with enough details to be useful for debugging and troubleshooting, while not cluttering the log with this information about requests that didn't experience errors.
Using New Debugging Features to Probe NGINX Internals
Learn how to use GDB to probe NGINX internals – you can write the debug log in memory and dump the active NGINX configuration