Help Center
Debug and optimize the log table in Moodle
Moodle installations often have peculiarities that other platforms do not have.
Administering and maintaining this e-learning platform can be a comprehensive topic.
Such is the case with the mdl_logstore_standard_log table, which stores user activity records and is generally very useful. However, the default configuration for saving these records is set to "Never delete logs." Therefore, if you have had a Moodle installation for several years with hundreds or thousands of students, this table can become problematic.
Configuring Auto-Deletion of Records
First, we need to log in to Moodle and go to:
Site administration > Plugins > Logging > Standard log
Once there, we should change the "Keep logs for" setting to a maximum of 1 year since the default configuration is "never delete logs."
This will be executed in the cron tasks.
Manually Cleaning the Table
When the records are too numerous, it may be necessary to perform manual cleaning.
To do this, we need to access the database directly. If your platform uses cPanel, you can use PHPMyAdmin.
Once there, select the database of your Moodle installation and go to the "SQL" tab.
Inside, we should write the following code:
DELETE FROM mdl_logstore_standard_log WHERE timecreated < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 190 DAY));
Replace the number 190 with the number of days you want to keep in the records.
It's essential to note that this operation can take a long time to complete, so it is recommended to perform it during periods of low user activity.
Related articles
- Error Handling Using PHP: A Comprehensive Approach to Different Statements
- Versions and extensions of PHP in cPanel
- Connect Visual Studio Code to cPanel using SSH
- Resolving Website Display Issues with DNS over HTTPS (DoH)
- Block IP addresses in cPanel, protect your website
- Interpreting a security scan of your files
- Resolve navigation issues by changing DNS settings in Windows and MacOS
- Configure a remote MySQL Connection
- How to point a website or domain to Wix?
- Connect your domain to Shopify
- What is a power pack?
- What is WP Accelerate and How to Configure It?