# How to Rotate Log Files in Fluentd?

Fluentd offers the capability to set up log rotation, particularly useful when managing large volumes of logs that consume significant disk space. This feature can be configured through Fluentd's system-wide settings.

Here is an example of a log rotation configuration in Fluentd that can rotate logs daily:

```text
[label /etc/fluent/fluentd.conf]
<system>
  <log>
    rotate_age 7
    rotate_size 1048576
  </log>
</system>
```

The configuration options are as follows:

- `rotate_age`: This parameter specifies the maximum age of log files in days before they are rotated. In this example, logs older than seven days will be rotated.
  
- `rotate_size`: This option defines the maximum file size in bytes for a log file before it gets rotated. Here, the file size threshold for rotation is set at 1MB.

Additionally, the `rotate_age` option can accept string values for more dynamic scheduling:

```text
[label /etc/fluent/fluentd.conf]
<system>
  <log>
    rotate_age weekly
    rotate_size 1048576
  </log>
</system>
```

Setting `rotate_age` to "weekly" means that the files will be rotated every week.

These settings are not limited to configuration files. You can also pass them as command-line arguments:

```command
fluentd -c fluent.conf --log-rotate-age 7 --log-rotate-size 104857600
```

[summary]
## 🔭 Want to centralize and monitor your logs?
Go to [Logtail](https://betterstack.com/logtail/) and start your log management in 5 minutes.
[/summary]
![Better Uptime Dashboard](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/08b5b6cb-f57b-4ff4-cf1d-b303b8a94e00/public =1247x768)