You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/api-platform/deploy/load-balancing-across-backend-servers). info

> [!NOTE]
> **Note:** The instructions in this page are applicable to Edge Private Cloud versions 4.50.00 and 4.51.00. For enabling log rotation on version 4.52.00, see [Enable log rotation for Edge
> components](https://docs.apigee.com/private-cloud/v4.52.00/enable-log-rotation).


Log rotation is a mechanism which is designed to ease administration of systems that generate
large numbers of log files. It allows automatic rotation, compression, removal and mailing of
log files.


In Edge for Private Cloud, some of the main log files on each of the Apigee components are configured with a
default rotation mechanism.


For example, on the Router component, the following files are configured with default rotation
mechanism:

- `/opt/apigee/var/log/edge-router/logs/system.log`
- `/opt/apigee/var/log/edge-router/logs/events.log`
- `/opt/apigee/var/log/edge-router/logs/startupruntimeerrors.log`
- `/opt/apigee/var/log/edge-router/logs/configurations.log`
- `/opt/apigee/var/log/edge-router/logs/transactions.log`


However, there are certain log files in Apigee components that are not configured with default
rotation. On the Apigee component Router `edge-router.log` file is one of those
files for which log rotation is not configured by default.


Log rotation can be enabled using different utilities/frameworks like `logrotate`,
`logback` or `log4j`. This document explains how to configure log
rotation for `/opt/apigee/var/log/edge-router/edge-router.log` file using
`logrotate` and `crontab`.

## Before you begin

- If you aren't familiar with `logrotate` configurations, read the [logrotate manual](https://linux.die.net/man/8/logrotate).
- If you aren't familiar with `crontab` configurations, read the [crontab manual](https://man7.org/linux/man-pages/man5/crontab.5.html).

## Enabling log rotation for edge-router.log on the Router


This section explains how to enable log rotation for
`/opt/apigee/var/log/edge-router/edge-router.log `logs on the Edge Routers.

> [!TIP]
>
> **Required permissions:**
>
>
> To perform this task, you must have the following permissions:
>
> - Access to the specific Routers, where you would like to rotate logs.
> - Access to create the `logrotate` conf files in the Edge Router component `/opt/apigee/edge-router/logrotate/ `folder.
> - Access to create a cron job using `crontab`.


The following steps describe how to enable log rotation for `edge-router.log` file.

1.
   Open the `/opt/apigee/edge-router/logrotate/logrotate.conf` file on the Router
   machine in an editor. If the file does not exist, create it. For example:

   ```
   vi /opt/apigee/edge-router/logrotate/logrotate.conf
   ```
2. Add a snippet to the file similar to the one shown below:

   ```
   /opt/apigee/var/log/edge-router/edge-router.log {
       missingok
       copytruncate
       rotate 5
       size 10M
       compress
       delaycompress
       notifempty
       nocreate
       sharedscripts
       }
   ```

   > [!NOTE]
   > **Note:** The sample configuration shown above rotates the file after 10 MB and log files are rotated five times before being removed. You can modify the above configuration depending on your log rotation requirements.

3. Save your changes.
4. Open apigee user's `crontab` using the following command:

   ```
   sudo crontab -u apigee -e
   ```
5. Add the following cron job to the Apigee user's `crontab`:

   ```
   0 0 * * * nice -n 19 ionice -c3 /usr/sbin/logrotate -f /opt/apigee/edge-router/logrotate/logrotate.conf
   ```

   > [!NOTE]
   > **Note:** The sample cron job shown above is scheduled to run at 00:00 AM every day. If you want this cron job to run at different times, you need to modify the time as needed.

6. Save the `crontab` and monitor log rotation during the next run of cron job.

## Verifying log rotation for edge-router.log on the Router

1. Once the scheduled cron job runs, the log file will be rotated. From the above example, cron job is scheduled to run every day at 00:00 AM to rotate the `edge-router.log` file.
2. Navigate to the `/opt/apigee/var/log/edge-router/` directory and verify that the `edge-router.log` file is rotated.

   **Sample listing of log files:**

   ```
   ls -ltrh | grep 'edge-router'
   ```

   ```
   -rw-r--r--. 1 apigee apigee 6.0K Feb 16 00:00 edge-router.log.1.gz
   -rw-r--r--. 1 apigee apigee 3.0K Feb 16 01:23 edge-router.log
   ```


   The above output indicates that the `edge-router.log` files are rotated and saved
   as GZ files.
3. If you don't see the `edge-router.log` files are being rotated, then verify that you have followed all the steps outlined in [Enabling log rotation for edge-router.log on the Router](https://docs.apigee.com/how-to-guides/enable-log-rotation-for-edge-router-log#enabling-log-rotation-edge-router-log) correctly. If you have missed any step, repeat all the steps again correctly.
4. If you are still not able to get the log rotation working, contact [Apigee Edge Support](https://docs.apigee.com/api-platform/troubleshoot/support).