Moodle log stores and log retention

How Moodle logs activity, where log entries can be written, how long they are kept and what log growth does to a self-hosted site. Use this to set retention that fits your evidence needs without slowing the database.

On this page

Moodle log retention: what your site records and how long it keeps it

Moodle records user activity in its standard log, and the answer to your compliance team's question depends on which log store is active, how long entries are kept and what your site actually writes. Start by confirming, in your own Moodle version, which log stores are enabled, what each one records, and what the log lifetime setting is. Do not assume a retention period from older documentation or from another site. Defaults and available settings have changed across releases, so check the Site administration pages for logging in the version you run, and record the values you find in your change records.

Activity logging in Moodle is a core feature, not an add-on, and it is the source for many reports that administrators and auditors use. An external database log store (the logstore_database plugin) is an option when you want log entries written to a separate database, which can reduce pressure on the main site database and gives you a place to apply your own retention. Two settings shape that design: the write buffer size, which controls how many entries are batched before they are written, and the list of actions the store can filter out. Filtering reduces volume but also removes evidence, so every excluded action should be a decision your compliance owner has signed off. The language strings for the store list these options, and the external database log store source is the natural place to confirm the exact labels in your version.

Growth in the log table affects backups, restore times and query speed on the main database, so retention is an operational decision with recurring work attached. Plan who owns log purging, how it is scheduled, how often a restore test confirms that the log data you need is still present, and how log exports are kept as evidence outside the live system. Ask your implementation partner or internal team to document the retention rule, the store configuration, the filtered actions and the storage location for exports, then test that an auditor's request can be answered from those records. Those steps are the practical content of log retention and they should be written down before the first audit request arrives.

Which log store fits which need

This is the simplest arrangement. Moodle writes activity events to its standard log store, and administrators and teachers read them through built-in reports. Operations stay inside the Moodle database, so there is no second system to provision, patch or back up. The trade-off is that the same database serves both learners and reporting queries, and the logs grow alongside course and user data. Access is governed by Moodle's own roles and capabilities, which suits teams whose reviewers already work inside the platform.

  • Operational load: The log table lives in the main database, so growth shows up in database size, backup duration and restore time.
  • Access control: Anyone granted report capabilities can see log data, so review which roles hold them.
  • Evidence handling: Logs are only as durable as the database backup and the retention settings applied to them.
  • Change effort: Retention and buffer choices are made in Moodle settings, with no new infrastructure.
  • Limits: Long-term analysis across other systems is harder to run from inside Moodle.

Before relying on this option, confirm which reports your auditors and teachers actually use and how long they need to see events.

Log configuration options and when each fits

This table compares the Moodle log settings that shape how much activity is recorded, how long it is kept and how much load it puts on the database. Read each row as a control you set, then check the trade-off column against your evidence needs and database capacity. The main takeaway is that every setting that increases coverage also increases storage, write load or query cost, so set them from a written retention requirement rather than from habit.

OptionWhat it controls and when to change itTrade-off between evidence, load and query speed
Enabled log storeWhich store receives events: the standard log, the external database store, or both. Confirm which stores are enabled in your environment before changing anything, since the choice decides where evidence lives.Keeping the standard log alone is simpler to operate. Adding the external database store adds a second write path and a second place to secure and back up.
Log lifetimeHow long log entries are kept before cleanup removes them. Set it from your documented retention requirement and confirm the period with your compliance or legal owner.Longer lifetimes preserve more evidence but grow tables and slow large queries. Shorter lifetimes reduce database size but may remove records you need for investigations.
Write buffer size (external database store)How many log entries the external database store collects before writing them in a batch. Raise it when write load on the database is high, and lower it when you need entries to appear quickly for monitoring.Larger batches reduce write operations but hold more entries in memory and delay visibility. Smaller batches keep data current but add write load.
Action filtering (external database store)Which event types are excluded from being written to the external store. Exclude only events your evidence plan does not need, and record each exclusion in your change log.Filtering lowers table growth and write load, but every excluded action is a gap in your audit trail that cannot be recovered later.
Event volume and table growthThe number of events your courses and users generate. Measure it over a representative period before choosing lifetime and filters, and review it after new plugins or integrations are added.High volume drives storage, backup size and query time upward. Reducing volume through filters or shorter lifetimes lowers cost but narrows what you can later prove.
Query and report loadHow often administrators, reports or external tools query the log tables. Limit heavy reports to planned windows if the log tables are large.Long retention with frequent unfiltered queries slows reporting. Indexed, scoped queries and separate reporting copies reduce impact but add operational work.
Evidence scopeWhether the chosen settings still capture the events an auditor, regulator or incident responder will ask for, such as sign-ins, grade changes and data exports.Broad coverage supports investigations and assessments. Narrow coverage is cheaper but may leave questions you cannot answer. Confirm the list with your assessors.

How log growth affects the database and backups

Log growth is a database sizing problem before it is a logging problem. Moodle writes a row to its log table for many user and system events, so a busy site with many courses, quizzes and logins can add rows quickly, and the log tables grow for as long as the log lifetime allows. Because the standard log lives in the main Moodle database, every extra row adds to the size of the database that you must store, back up, copy and restore. Before you set a log lifetime, ask your Moodle administrator or hosting team to confirm how many rows the log tables gained over a typical week, during term start and during exam periods, and how that compares with the current database size.

The effects reach three places. Larger tables make a full database backup bigger and slower to write, so the backup window and the storage you keep for each retained copy both grow. A restore has to load the same rows before the site is usable, which lengthens recovery time for the whole platform, not just the logs. Query performance also suffers when reports and the logs report scan large tables, and the cost is felt most during peak use. Retention therefore has to be planned together with database sizing and with backup retention: if you keep backups for longer than logs are needed, the logs you purge still exist in older backups, and if you purge logs aggressively but keep long backups, the purge does not reduce your storage at all.

Measure growth in your own environment before you set any lifetime value. Record the database size and the row counts for the log tables at regular intervals across a full term, then calculate the daily increase and project it against your storage and backup targets. If you send logs to an external database through the logstore_database store, confirm where the growth lands and whether the external database has its own sizing and backup plan, since the main database may still hold the standard log. Use these measurements to agree the retention period, backup retention and restore time target together, and rerun the measurement after major course or plugin changes.

Setting up external database logging and retention

This sequence moves Moodle's activity logging into a dedicated external database with controlled batching, filtered actions and a defined log lifetime. The result is a log store you can verify end to end and explain to auditors.

  1. Confirm the Moodle version and enabled log stores

    The Moodle administrator checks the running version under Site administration, then opens the log store settings page to see which stores are enabled and in what order. Confirm that the version is one your change plan covers, since the database engine versions and upgrade paths differ between releases (check the Moodle 5.1 and 5.3 release notes for the requirements that apply to you). Record the current standard log settings, including the log lifetime, so you can compare later. The step is done when you have a written baseline of the version, enabled stores and current retention values.

  2. Create a dedicated logging database account

    The database administrator creates a separate database or schema for log entries and a dedicated account that can write to and delete from it, and nothing else. Keep this account apart from the account Moodle uses for its main database, so a compromise of one does not expose the other, and so that log data can be governed on its own terms. Confirm the account's privileges with a test connection from the Moodle application server, using the same network path and TLS settings Moodle will use. The step is done when the account connects from the Moodle host and cannot read tables outside the log schema.

  3. Configure the external database log store

    In Moodle, the administrator enables the external database log store and enters the connection details for the logging database, including the database type, host, port, table name and credentials. Set the write buffer size, which controls how many entries are batched before they are written, and decide whether the standard log store stays enabled alongside it. Save the settings and confirm that Moodle reports a successful connection and creates or accepts the expected table. The step is done when the store shows as enabled with a valid connection and no error on the settings page.

  4. Set action filters for the external store

    The administrator reviews the list of event types the external store can exclude and decides which high-volume, low-value actions to filter out, while keeping the events your investigations and evidence needs. Document each filter with its reason, because the filter list becomes part of what you explain to auditors about what is and is not recorded. Apply the filters in a non-production copy first if you have one. The step is done when the filter decisions are written down and the active filters match that record.

  5. Set the log lifetime

    The administrator sets how long log entries are kept in the log store, using the log lifetime setting that applies to the stores in use. Align the value with your retention policy and with any legal hold or audit requirement you have confirmed with your compliance lead, rather than choosing a number from habit. Be aware that removing entries is a scheduled cleanup, so the value you set determines what is deleted on each run. The step is done when the lifetime is recorded in your configuration documentation with its approval reference.

  6. Verify that test actions reach the external database

    Perform a known set of actions in a test course, such as viewing a page, creating a forum post and logging out, then wait for the write buffer to flush. Query the external log table directly and confirm the entries appear with the expected user, course, event name and timestamp, and that filtered actions are absent. Because writes are batched, a missing entry may simply be waiting in the buffer, so check again after a flush before treating it as a fault. The step is done when every test action you performed is present and every filtered action is absent.

  7. Verify that the lifetime cleanup runs as scheduled

    Confirm that Moodle's scheduled cleanup task for logs is enabled and running under cron, and check its last run time in the scheduled task report. Use a controlled test set, such as entries you created with a timestamp older than the lifetime in a non-production copy, to confirm that the cleanup removes them on the next run. Check that entries inside the lifetime remain untouched and that the table is not left in an inconsistent state. The step is done when the task report shows a recent successful run and the test entries outside the lifetime are gone while retained entries remain.

Protecting logs as evidence

Moodle's log tables and any external log database can become evidence in an investigation, an audit or a dispute about who did what. The cards below cover the controls that keep those records trustworthy, from who can reach the database to how long entries are kept and what personal data they contain.

Restrict access to the logging database

If the standard log or an external log store sits in the Moodle database, anyone with database credentials can read or alter it. Check which accounts can query the log tables, including backup and replica users, reporting tools and DBAs. For an external log store, give the Moodle web and cron processes write-only access where the database allows it, and keep read access to a small named group. Record who holds each credential and review that list on a fixed schedule.

Separate Moodle administrators from log readers

A Moodle site administrator can change settings, roles and plugins, and can also view reports built on log data. When the same person can change behavior and review the record of that behavior, the log loses value as evidence. Assign report and log viewing capabilities to a separate role, and limit who can change log store settings, buffer size or excluded actions. Confirm in your own environment which default roles include these capabilities before you rely on them.

Protect exported logs from tampering

Exported log files and report downloads can be edited after they leave Moodle, and nothing in a plain CSV proves it is complete. Store exports in write-once or access-controlled storage, record a checksum when each export is created, and note the date range, filters and person who ran the export. Ask your auditor or legal team which format and chain-of-custody steps they expect before the first export is needed.

Handle personal data in log entries

Log entries usually hold user IDs, IP addresses, course identifiers and the actions users take, and some plugins write more detail into the event data. Identify which fields in your log store count as personal data under your privacy rules, and decide who may see them. Confirm with your privacy office whether pseudonymous IDs are enough for your investigations or whether identifiable fields must be available, since that choice shapes access controls and retention.

Align retention with organizational policy

Log lifetime is a configuration choice, and the setting that removes old entries can run without anyone reviewing it. Write down how long logs must be kept for security, audit and dispute purposes, then set the Moodle log lifetime to match and check that the cleanup task runs. Remember that logs deleted by Moodle are gone unless you copied them elsewhere first. Agree the retention period and the deletion procedure with your records and compliance owners.

Questions about Moodle log retention and cost

What drives the effort of setting up an external log database for Moodle?

The main drivers are the state of the existing database, how many log entries the site writes, and how many actions you choose to keep. A site with a clean, dedicated database server and a modest event volume is far simpler than one where the external store shares a busy production database. Work also grows when you need to map the store to your existing reporting, confirm which actions are filtered, and tune the write buffer size so batches are written without delaying page requests. Each of these is a configuration and testing task, so ask the vendor to break effort down by these items rather than quoting a single lump sum.

Can our own team set up Moodle log retention without a partner?

Often yes, if you have a Moodle administrator who can enable the external database log store, a database administrator who can create the target database and account, and someone who can test the result. The Moodle log store configuration is a small part of the job. The harder parts are agreeing what must be kept, proving that the external store receives the events you expect, and documenting the setup so it survives staff changes. Decide early which of these your team has time and skill to own, and bring in a partner for the parts you cannot staff.

What does the work need from our team before it starts?

Expect to provide four things: access to create or grant rights on a dedicated log database, a written retention and filtering decision from the people accountable for records, a non-production Moodle environment where changes can be tested, and a named contact who can approve changes to the production site. Without database access and a test environment, the work moves into production windows, which increases risk. The retention decision is the one most often delayed, so start that conversation with compliance and records owners at the outset.

How long should Moodle keep activity logs, and who decides?

The retention period is a policy decision, not a technical one. Legal, compliance, records management and the teams that rely on the logs for investigations or accreditation should set it, usually from the obligations that apply to your sector and jurisdiction. Moodle's log lifetime setting controls how long entries stay in the standard log, and the external store has its own retention in your database. Confirm the required period with your legal and compliance owners and record who approved it, because the technical configuration only implements that decision.

Does log growth affect our database performance and costs?

Yes. Log tables grow with every tracked action, so a busy site with long retention can see its database grow steadily, increasing storage use, backup size and the time taken by queries that scan log data. Storage cost is recurring, while the setup is one-time. To control it, review which actions you record, set a retention period that matches the policy, and check that purge jobs run successfully. Ask any partner to show how they will measure growth and where the external store will sit relative to backups and replicas.

What should a quote for Moodle log retention include?

A useful quote lists the scope in writing: the log stores to be configured, the target database and its sizing assumptions, the actions to include or filter, the retention rules, and how the setup is tested in a non-production environment. It should name deliverables such as configuration notes and a verification record, state what the client must provide, and separate one-time work from any recurring support or review. Ask how the quote handles changes to the retention policy later, and whether backup and restore of the log database is included.

Can Moodle logs be used as evidence in an audit or investigation?

Logs can support an investigation or audit only if they are complete for the period in question, protected from change, and retained for as long as the policy requires. Confirm with your compliance and legal owners what evidence standard applies, who may access the logs, and how exports are recorded. Verify that the external store captures the events you rely on, because filtered actions will not appear. DeployOpen prepares systems and evidence for compliance assessments, but independent auditors and certification bodies decide whether that evidence is sufficient.

How a Moodle event reaches the log stores

A user action in Moodle is recorded as an event and passed to the log manager, which writes it to the standard log store in the Moodle database. When the external database log store is enabled, the event is held in a write buffer and written in batches to a separate logging database, using a database account that Moodle's application code does not share. Check the buffer size, the filtered actions and the lifetime cleanup settings on both stores, since the database account boundary decides who can alter the evidence.

Events flow from user actions to the standard and external log stores.

How DeployOpen scopes Moodle logging and retention

DeployOpen plans Moodle log stores and log retention as part of the platform build, not as an afterthought. We agree what gets logged, where it lives, how long it is kept and who can read it, then implement and document those settings in infrastructure you control.

How we scope

  • Written scope covers the standard log store, any external log database, and the retention period for each log source.
  • We record which compliance, audit or investigation needs drive how long activity logs must be kept.
  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we build

  • We configure log stores and write buffer size, then test that expected events reach the external database.
  • We set action filters deliberately and check that the events you need as evidence are not filtered out.
  • We model database growth from your activity volume and test cleanup jobs and table sizing before go-live.

How we hand over

  • You receive a retention schedule, log store configuration record and a runbook for changing settings safely.
  • Documentation explains who can read logs, how exports are produced and how logs are preserved for review.
  • We walk your administrators through checking log growth, buffer health and cleanup results on their own.

How we support

  • Ongoing support and upgrade work for Moodle log configuration is available as a retainer.
  • Retainers can include periodic reviews of log growth and retention settings after each Moodle upgrade.
  • We can retest logging and retention after infrastructure or database changes, so evidence stays reliable.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.