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.

Last updated: 25 de abril de 2024

Estimated reading time: 2 minutes

Did this article help you?
Let's Do It!

Start TODAY for only $2.45/month

Includes a web builder, 30GB of cloud storage, +200 Apps, and professional email.

Sign Up Now