LUA log format

609 views
Skip to first unread message

Martin Gee

unread,
Dec 10, 2014, 8:58:24 PM12/10/14
to openre...@googlegroups.com
I'm using the directive:

error_log syslog:server=127.0.0.1,tag=app1tag info;

In LUA code I'm using:

ngx.log(ngx.INFO, auditstuff)

Which generates: 

Dec 11 01:42:08 spg-dev2 app1tag: 2014/12/11 01:42:08 [info] 26544#0: *704 [lua] authSession.lua:31: audit(): "USER_REQUEST_AUTHZ" SESSION_ID:"_9d25b0d4a16ae6fbd33c2f1c9129e3b26e433a8471" SUBJECT:"us...@gmail.com" RESULT:"ALLOW" RESULT:"NA - UserName=us...@gmail.com RemoteIP=10.123.123.123 RelayDomain=app1.spg-dev2.domain.info firstName=Martin lastName=Gee Groups=Portal Sales Group:Portal Admin Group:Portal Authorizer Group:Everyone ", client: 10.123.123.123, server: app1.spg-dev2.domain.info, request: "GET /logo.png HTTP/1.1", host: "app1.spg-dev2.domain.info", referrer: "https://app1.spg-dev2.domain.info/"

My question,  can we define our own log format while logging via ngx.log .... (syslog)?

Yichun Zhang (agentzh)

unread,
Dec 11, 2014, 3:24:44 PM12/11/14
to openresty-en
Hello!

On Wed, Dec 10, 2014 at 5:58 PM, Martin Gee wrote:
> My question, can we define our own log format while logging via ngx.log
> .... (syslog)?
>

Well, ngx.log() is for error logging. And it just invokes nginx core's
error logger, which does not support custom format, unlike the access
logging.

On suggestion is to use nginx's access logger for this or just use
lua-resty-logger-socket with which you have the maximum freedom:

https://github.com/cloudflare/lua-resty-logger-socket

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages