Audit data can get very large, very quickly. Audit comes bundled with a command to help you manage the data.
A command is available to cleanup old data, which can be added to your cron.
php yii audit/cleanup [options] options: --entry - True to cleanup the AuditEntry. --panels - Comma separated list of panels to cleanup. --age - Max age in days to cleanup, if null then the panel settings are used.
Cleanup all data based on the Module and Panel settings:
php yii audit/cleanup
Cleanup all data by specifing
0 as the max age:
php yii audit/cleanup --age=0
Cleanup all data older than 30 days:
php yii audit/cleanup --age=30
Cleanup only data from LogPanel and ProfilingPanel older than a week
php yii audit/cleanup --panels=audit/log,audit/profiling --age=7
In addition to being able to specify the
age as an argument to the command, each panel has a
property which specifies the number of days to keep the data. By default this is
NULL, which means data
will never be removed.
<?php $config = [ 'modules' => [ 'audit' => [ 'class' => 'bedezign\yii2\audit\Audit', 'maxAge' => 30, // 30 days 'panels' => [ 'audit/log' => [ 'maxAge' => 7, // 7 days ], ], ], ], ];