You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/api-platform/reference/policies/message-logging-policy). 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*---the process of rotating multiple log files in and out of use---
simplifies administration of systems that
generate large numbers of log files. Log rotation enables automatic rotation, compression,
removal, and mailing of log files.

In Edge for Private Cloud, some of the main log files on each `apigee`
component are configured with a default rotation mechanism. For example, on the
Message Processor component, the following files are configured with a default rotation
mechanism using logback:

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

Similar files exist for other `edge-*` components (whose names
begin with `edge-`), such as `edge-management-server`,
`edge-router`, `edge-postgres-server`, and `edge-qpid-server`.
Each of these `edge-*` components also generate an additional log file that is a redirected output of the respective component's console. In the case of the Message Processor component, this file is called `/opt/apigee/var/log/edge-message-processor/edge-message-processor.log`. Other `edge-*` components generate a similar file. These files' rotation are not done by the logback library, but rather using `logrotate` and `crontab`.

<br />

### 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).

## Enable log rotation

This section applies to Edge for Private Cloud versions 4.50.00 and 4.51.00.


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.


By default, some of the main log files on each of the `apigee` components are configured with a
default rotation mechanism.
For example, on the Message Processor component, the following files are configured with default
rotation mechanism:

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


However, other log files in `apigee` components are not configured with default rotation.
For example, log rotation is not configured by default on the `apigee` component Message
Processor file `edge-message-processor.log`.


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

### Enabling log rotation for edge-message-processor.log on Message Processors


This section explains how to enable log rotation for `/opt/apigee/var/log/edge-message-
processor/edge-message-processor.log `logs on the Edge Message Processors.

> [!TIP]
> **Required permissions:** To perform this task, you must have the following permissions:
>
> - Access to the specific Message Processors, where you would like to enable rotate logs.
> - Access to create the `logrotate` conf files in the Message Processor component `/opt/apigee/edge-message-processor/logrotate/ `folder. The `logrotate.conf` file must be owned by the `root` user. Log rotation will fail if the file ownership is incorrect.
> - Access to create a cron job using `crontab`.


The following steps describe how to enable log rotation for
`edge-message-processor.log` file:

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

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

   ```
   /opt/apigee/var/log/edge-message-processor/edge-message-processor.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 the `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 -s /opt/apigee/var/run/edge-message-processor/logrotate.status -f /opt/apigee/edge-message-processor/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-message-processor.log on the Message Processor

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-message-
   processor.log` file.
2.
   Navigate to the `/opt/apigee/var/log/edge-message-processor/` directory and
   verify that the `edge-message-processor.log` file is rotated.

   **Sample listing of log files**

   ```
   ls -ltrh | grep 'edge-message-processor'
   ```

   ```
   -rw-r--r--. 1 apigee apigee  17K Feb  7 00:00 edge-message-processor.log.1.gz
   -rw-r--r--. 1 apigee apigee 5.3K Feb  7 09:12 edge-message-processor.log
   ```


   The above output indicates that the `edge-message-processor.log`
   files are rotated and saved as a GZ file.
3. If you don't see the `edge-message-processor.log` files are being rotated, then verify that you have followed all the steps outlined in [Enabling log rotation for edge-message-processor.log on Message Processors](https://docs.apigee.com/how-to-guides/enable-log-rotation-for-edge-message-processor-log#enabling-log-rotation) 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, then contact [Apigee Edge Support](https://docs.apigee.com/api-platform/troubleshoot/support).