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
ngx.log(ngx.DEBUG, "encrypted data: ", resty_str.to_hex(data))
I tried os.getenv("KONG_LOG_LEVEL")
but that returns nil even when the log level was configured through an environment variable. I am locally running kong as a docker container but that shouldn’t have any impact I think.
Kindly share your expert inputs.
Thanks.
hi there could you try:
local errlog = require "ngx.errlog"
local log_level = errlog.get_sys_filter_level()
and see if that works? we should add a pdk function here as well.
Thanks for your inputs. I will try this out.
What is a pdk function?
the pdk is our plugin developer kit where you can call kong.
type functions. we (i.e. us at Kong) should add a function in the pdk to support getting the log level in the future - which could look like kong.get_log_level()
. for now please try the suggestion i responded with - cheers.
It seems this one liner kong.configuration.log_level == "debug"
also does the job. This sounds better than the earlier solution. Any side effects?