APISIX Custom Lua Plugins - How do I write logs to a file?

56 Views Asked by At

I have created a custom lua plugin which does authentication of a token and sets a few fields to headers before sending requests to upstream in apisix. I can use ngx.log to print logs on console. However I would like to write these logs to a file and also have a rolling file appender logic implemented. I used a library called https://lunarmodules.github.io/lualogging/ for rolling file appenders. However these logs are not working in rewrite phase(this is the phase where all my custom lua logic sits).

I don't understand why am I not able to write logs to a file in rewrite phase. The logs are also not getting stored in access.log and error.log files which is a nginx default feature.

0

There are 0 best solutions below