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