Set the size of the logging file audit.log (log rotate)

You should do logrotation by the logrotate daemon instead of the nextcloud server itself.
Unfortunately I could not find any information about your operating system but my example is for debian like operating systems like Ubuntu.

First of all, move your logfiles out of the netcloud data directory to /var/log/nextcloud/*

sudo mkdir -p /var/log/nextcloud
sudo chown www-data.www-data /var/log/nextcloud

Create this file (change the value of size to your needs):
/etc/logrotate.d/nextcloud

var/log/nextcloud/*.log {
    rotate -1
    su www-data www-data
    size 10485760
    missingok
    create 640 www-data www-data
    compress
    delaycompress
}

Change the log settings from your config.php (example like I use it):

config/config.php

  'logtimezone' => 'Europe/Moscow',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'logfile_audit' => '/var/log/nextcloud/audit.log',
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'admin_audit',
    ),
  ),
  'log_query' => false,
  'loglevel' => 2,
  'log_rotate_size' => 0,

With 'log_rotate_size' => 0,Nextcloud does not logrotate at all and so it can be carried out by the operating system’s logrotate service, which is much more suitable for this purpose.

Hope this helps!

Much luck,
ernolf

1 Like