How to call certain functions only when log level is DEBUG in plugin? #13474
-
We are deploying kong 3.1.1 through helm on kubernetes in our environments. For performance reasons we want to restrict the call to certain modules and functions only when the log level is DEBUG. How do get to know the log level in the kong plugin handler.lua file? The logging is done through I tried Kindly share your expert inputs. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
How did you set the env environment in your deployment? could you try testing with other deployment method like local build from source, to make sure it's a functional issue or something wrong in k8s deployment logic? |
Beta Was this translation helpful? Give feedback.
-
You can use: if kong.configuration.log_level == "debug" then
...
end The env vars with nginx are only available on You obviously don't need to wrap any |
Beta Was this translation helpful? Give feedback.
You can use:
The env vars with nginx are only available on
init
phase, but not with workers. You can also placeos.getenv
on module level of yourhandler.lua
as handlers are loaded on init phase. But I think it is better to use above.You obviously don't need to wrap any
ngx.log
orkong.log.debug
with that.