# Kong API Gateway - enabling log rotation

**URL:** https://discuss.konghq.com/t/kong-api-gateway-enabling-log-rotation/11990
**Category:** General
**Tags:** kong-gateway
**Created:** [October 16, 2023, 2:20pm UTC](https://discuss.konghq.com/t/kong-api-gateway-enabling-log-rotation/11990 "2023-10-16T14:20:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ddesai](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@ddesai](https://discuss.konghq.com/u/ddesai)
#### Post date: [October 16, 2023, 2:20pm UTC](https://discuss.konghq.com/t/kong-api-gateway-enabling-log-rotation/11990/1 "2023-10-16T14:20:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![JohnWilliams](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/johnwilliams/32/4230_2.png) [@JohnWilliams](https://discuss.konghq.com/u/JohnWilliams)
#### Post date: [October 16, 2023, 2:38pm UTC](https://discuss.konghq.com/t/kong-api-gateway-enabling-log-rotation/11990/2 "2023-10-16T14:38:18Z")

</div>

@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](https://github.com/Kong/kong-build-tools/blob/master/kong.logrotate) and restart the logrotate process,

```auto
/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.

---

<div class="post-metadata">

### Author: ![ddesai](https://avatars.discourse-cdn.com/v4/letter/d/5f8ce5/32.png) [@ddesai](https://discuss.konghq.com/u/ddesai)
#### Post date: [October 16, 2023, 2:58pm UTC](https://discuss.konghq.com/t/kong-api-gateway-enabling-log-rotation/11990/3 "2023-10-16T14:58:22Z")

</div>

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
