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.
Nginx+Lua is a self-contained web server embedding the scripting language Lua. Powerful applications can be written directly inside Nginx without using cgi, fastcgi, or uwsgi. By adding a little Lua code to an existing Nginx configuration file, it is easy to add small features.
Some older versions of Nginx don't support native loading of Lua modules. Therefore, we require Nginx to be built with Lua and LuaJIT support.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With