No logs is geeting generated

I am getting following error : {“message”:“An unexpected error occurred”} while calling an api enabled with custom plugin

There are no error logs getting generated . Where to see what went wrong?

curl -X POST http://kong:8001/apis
–data name=headers-api
–data uris=/headers
–data strip_uri=false
–data upstream_url=https://httpbin.org

curl -X POST http://kong:8001/apis/headers-api/plugins
–data name=middleman \

 curl -X POST http://kong:8001/apis/headers-api/plugins \
--data "name=middleman" \
--data "config.url=http://dockerApi:8092/api/dockets" \
--data "config.response=table" \
--data "config.timeout=10000" \
--data "config.keepalive=60000" \
--data "config.body_data"="{ \"title\": \"foo\",\"body\": \"bar\",\"userId\": 1 }"

Hi,

There are no error logs getting generated.

There most certainly are logs, but you might be looking for them in the wrong place. If you read the current configuration of your Kong node, like so:

$  curl -s http://kong:8001 | jq '.configuration.admin_acc_logs'

You will get the path at which Kong writes error logs for the Admin API. Source: https://docs.konghq.com/latest/admin-api/#retrieve-node-information. (Note the use of jq in the above command, for brevity).

The path for Admin API error logs is most likely to be the same as that of the proxy, unless you configured it to be different. By default in the current latest release, both point to <prefix>/logs/error.log.

Where are you looking for those logs right now? If you are still having problems locating them, please indicate which version of Kong you are using. Most likely, this is an issue with the middleman plugin, and you would have to report it to its author, as we are not responsible for its maintainership.

Hi
There no entry in the logs you mentioned above. Any how thanks for the input…
I was looking for a plugin that will do role based authorization with JWT token validation

Do you have any idea abt custom plugin which does that?

Like I said, the file I mentioned might not necessarily be the file that you should be looking into. Please share more information with us: what is the log_level you configured for your Kong node? And which prefix is Kong running into, as well as what are the files in the <prefix>/logs directory? When such an internal error happens, Kong/OpenResty does generate a log at the error level.

Hi
I could see logs when I run docker kong container logs

Here are the following properties

log_level = “notice”

prefix = “/usr/local/kong”

If you run the Kong docker image, then logs are indeed written to stdout/stderr. The more we know about how you are running Kong, the better we can help you. You were able to see the logs right?

I am running Kong docker image I am able to see logs in stdout/stderr which are container logs.

But when I see in the container /usr/local/kong/access.log and /usr/local/kong/error.log . these are empty files.

Please let me know what information is required by you to know why logs are not getting created in desired location

The docker images purposefully writes logs to stdout/stderr instead of writing them to files within the container, and for good reason. With lack of support for rotting logs out of the container, writing them to a file within the container would fill the disk space available to your container, causing it to crash. This has happened to some users in the past. Your monitoring solution should consider playing nice with the container logs, this is perfectly normal.

Thanks @thibaultcha for your support. Just one question which is not related to the current issue which as follows:

Is it possible to achieve changing priority of kong built in plugins precedence of execution while enabling them?

Is it possible to achieve changing priority of kong built in plugins precedence of execution while enabling them?

No, not without forking them as of today at least. Since this is already being discussed at Overide plugin priority : Custome priority, let’s not diverge from the original topic here and let’s keep each discussion separate from each other, thanks :slight_smile: