How to Limit the aria2 Log File Size Before It Rotates?

The size of the aria2 log file is controlled and limited by the --log-max-size parameter. When the log file reaches the threshold defined by this setting, aria2 automatically rotates the log, renaming the old file and starting a fresh one. By default, this parameter is set to 10 MiB (10 megabytes), which prevents the log file from growing indefinitely and consuming excessive disk space during long-running download sessions.

Understanding the --log-max-size Parameter

When running aria2c with logging enabled via the --log parameter, the application records various levels of internal activity. Without a cap, these files can quickly become massive, especially when downloading large torrents with many peers.

The --log-max-size parameter accepts a size value that defines the upper limit before rotation triggers. You can specify the size using standard suffixes:

Configuration Example

To set a custom log size limit, you can pass the parameter directly in the command line or add it to your aria2 configuration file (aria2.conf).

For example, to limit the log file to 5 Megabytes before it rotates, use the following command:

aria2c --log=aria2.log --log-max-size=5M https://example.com/file.zip

If you prefer to make this change permanent, add the following line to your aria2.conf file:

log-max-size=5M

How Log Rotation Works in aria2

Once the active log file hits the maximum size specified by --log-max-size, aria2 handles the rotation automatically:

  1. The current log file (e.g., aria2.log) is closed.
  2. It is renamed to include a suffix, typically saving it as the old log.
  3. A brand new aria2.log file is created to continue recording new events.

Note: Aria2 only keeps a limited history of rotated logs to save disk space. If you require long-term retention of massive logs, consider pairing aria2 with system-level utilities like logrotate on Linux.