How to customize KONG log file name? (For example, we expected the access log file name is kong-access-{hostname}-{yyyymmdd-hhmmss}.log)

Hi All,
Good morning.
We want to customize KONG log file name, and we have tried few ways to implement this requirement, but finally, we don’t successful. So, I come to here to see if someone have any solution to fix my problem. Thanks for your help in advance.
Environment:
Platform: k8s
Kong Version: 2.0.4
I have tried below methods:

  1. Modify shell script ‘docker-entrypoint.sh’
    a) Modify shell script ‘docker-entrypoint.sh’ make sure ‘/dev/stdout’ and ‘/dev/stderr’ associate to log file.

b) Set the log related env in k8s YAML file

Result:
After we recreated the k8s prod, we found the log file has created and also associated with ‘/dev/stdout’ and ‘/dev/stderr’. But no any log Info write to the log files.

  1. Modify lua script ‘nginx_kong.lua’
    We modified below highlighted line, its original line is ‘access_log ${{PROXY_ACCESS_LOG}};’

Result:
After we recreated the k8s prod, we found the access log file name is ‘kong_access.log’ not ‘kong_access${{HOSTNAME}}.log’, and we are sure the environment variable ‘HOSTNAME’ exists in kong POD. We also sure the log can right write to file ‘kong_access.log’, but the file name doesn’t contain the value of env ‘HOSTNAME’.

Sincerely wish you and your family happiness.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ