Small question about ngx.log()

33 views
Skip to first unread message

Didip Kerabat

unread,
Sep 26, 2016, 1:10:30 PM9/26/16
to openresty-en
Can I make modification to it?

For example, I just want to output the content of my log without being prefixed with timestamp or line number?

The use case is: I'd like to log a full JSON payload to the log file.

I tried print, but it's the same as ngx.log(ngx.notice, ...)

Docs I've read:
https://github.com/openresty/lua-nginx-module#ngxlog
https://github.com/openresty/lua-nginx-module#nginx-log-level-constants

Robert Paprocki

unread,
Sep 26, 2016, 1:12:59 PM9/26/16
to openre...@googlegroups.com
Hi,

On Mon, Sep 26, 2016 at 10:10 AM, Didip Kerabat <did...@gmail.com> wrote:
Can I make modification to it?

For example, I just want to output the content of my log without being prefixed with timestamp or line number?

The use case is: I'd like to log a full JSON payload to the log file.

I tried print, but it's the same as ngx.log(ngx.notice, ...)

ngx.log hooks into the Nginx error logging subsystem, so there's no way to accomplish this directly.

You could use the Lua IO library (not recommended in high concurrency/performance sensitive environments), or have a look at something like https://github.com/cloudflare/lua-resty-logger-socket which can buffer log data and ship it to a remote TCP or UDP server (say, something like a local syslog server).

Good luck with it!
Reply all
Reply to author
Forward
0 new messages