Kong API Gateway - enabling log rotation

Hello Kong community,

This is my first post to the community. We are trying to figure out how to enable log (access.log, messages etc ) rotations for Kong API gateway, our gateways are deployed on EC2 instances (CentOS Linux release 7.9.2009 (Core)). Please let me know if additional information required?

Appreciate your help!

Best,
Dhiren

@ddesai - Welcome to Community.

Find your log rotate config folder and add the config specific to your logs files. Its usually under,

/etc/logrotate.d/

Create a new entry file say kong-nginx and add below entry and restart the logrotate process,

/usr/local/kong/logs/*.log {
  su kong kong
  rotate 14
  daily
  missingok
  compress
  delaycompress
  notifempty
  sharedscripts
  postrotate
  if [ -f /usr/local/kong/pids/nginx.pid ]; then
    kill -USR1 `cat /usr/local/kong/pids/nginx.pid`
  fi
  endscript
}

Let me know if it helps.

Hey @JohnWilliams,

Appreciate the very quick response and help. This is very helpful, we had some idea, didn’t knew the exact step.

Thank you!

Best,
Dhiren