How to Manage Domain Log Rotation in Plesk

November 27, 2023 / Plesk

In Plesk, log rotation for a domain refers to the process of managing and maintaining log files by occasionally archiving and/or deleting older logs to stop them from consuming excessive disk space. Log rotation is essential for keeping the server storage organised and avoiding potential issues related to disk space exhaustion.

Via control panel:

  1. Log in to Plesk.
  2. Select the Domains option under Hosting Services.
    domains
  3. Select the domain whose log rotation you wish to manage.
    domains
  4. Click on the Logs option.
    logs
  5. You will enter the logs of that domain.
  6. Click on the Log rotation.
    logs
  7. A pop-up window will appear. Fill in the required parameters –
    1. Tick the “Log rotation” checkbox.
    2. Select the “Log rotation condition” by time or by size.
    3. Enter the maximum number of log files.
    4. Tick the “Compress log files” checkbox.
    5. Add the email address to the email log files after Plesk retrieves data from the log files of the web and FTP servers.
  8. Finally, click on the “Ok” button.
    configure log rotation

Important notes:

  • When Log rotation is not enabled, log files will be retained indefinitely.
  • If the Maximum number of log files is configured as zero, all current log files will be deleted during log rotation.
  • ModSecurity log files are rotated solely based on their size.

Via Command Line Interface (CLI)

You can manage domain log rotation in Plesk using the command line on both Linux and Windows servers.

Command Syntax:
Use the following command structure:
plesk bin site –update <domain-name> [options]

Available Log Rotation Options

  • -log-rotate <true|false>
    Enable or disable log rotation
  • -log-bysize <number>[B|K|M|G]
    Rotate logs when they reach a specified size
  • -log-bytime <daily|weekly|monthly>
    Rotate logs based on time (default: daily)
  • -log-max-num-files <number>
    Maximum number of log files to keep
  • -log-compress <true|false>
    Enable or disable log file compression
  • -log-email <email>
    Send rotated log files to an email address

Example: Enable Log Rotation for a Domain

The following command:

  • Enables log rotation
  • Rotates logs when they reach 5 MB
  • Keeps a maximum of 3 log files
  • Compresses rotated logs
  • Emails log files to [email protected]
plesk bin site --update example.com \
-log-rotate true \
-log-bysize 5M \
-log-max-num-files 3 \
-log-compress true \
-log-email [email protected]

Example: Disable Log Rotation

plesk bin site --update example.com -log-rotate false

Example: Disable Email Notifications for Log Rotation

plesk bin site --update example.com -log-email ""

Important Notes:

  • If log rotation is disabled, log files are stored indefinitely.
  • Setting -log-max-num-files 0 deletes all existing log files during rotation.
  • ModSecurity logs are rotated only by size, regardless of time-based settings.

Stay updated on insightful articles by regularly visiting our Knowledge Base (KB) section. If you need assistance, our support specialists are here to help.

Spread the love