How to debug lua code inside nginx config?

0

Issue

I want to insert log points (io.write) inside my lua code which itself is in nginx configuration (using HttpLuaModule for nginx).
How to do that?
Access and error logs are not showing them.

Solution

When running under nginx, you should use ngx.log. E.g:

ngx.log(ngx.STDERR, 'your message here')

For a working example, see http://linuxfiddle.net/f/77630edc-b851-487c-b2c8-aa6c9b858ebb

For documentation, see http://wiki.nginx.org/HttpLuaModule#ngx.log

Answered By – mikaraento

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More