How do I enable logging on Kong tests?

So I’ve got an integration test executing, it’s literally a copy & paste of the one on https://getkong.org/docs/0.13.x/plugin-development/tests/ (I’ve implemented my-plugin as an empty extension of BasePlugin as per: https://getkong.org/docs/0.13.x/plugin-development/custom-logic/ (except I haven’t overwritten any functions)

The test times out when sending the request to proxy client, but I don’t have any information about what went wrong. Did Kong receive my request? Did the test server start properly? Did my plugin execute?

I can see in spec/helpers.lua: the log level is set to quiet, changing that line to set it to debug gets me some logs, but it seems like it only logs from the process running the specs, and has no impact on the process it kicks off running Kong in openresty.

So, I guess the question is, where can I find/configure the logs for the nginx/openresty process that the spec starts?

FWIW I figured this out.

Nginx creates a ./servroot folder which is then deleted in the teardown function of the test (stop_kong within helpers.lua)

It is also possible to increase the verbosity of the nginx logs by adding --v to this line:

Then you actually get stack traces for when your plugin fails inside an integration test invocation, which is massively useful and should probably be default behaviour

3 Likes