Duplicator Documentation

Documentation, Reference Materials, and Tutorials for Duplicator

Want it done for you?

Let the Duplicator experts migrate your WordPress site for you — quick, safe, and hassle-free.

Get Migration Help

Using WP-CLI with the Activity Log


Wondering how to export or clean up your activity log without opening wp-admin? The Activity Log plugin includes WP-CLI commands for exporting log data and purging entries straight from the command line.

This guide covers using WP-CLI with the Activity Log plugin, including every available export and purge flag.

Requirements: To use the Activity Log plugin, you’ll need an Activity Log license or a Duplicator Pro Elite license.

Requirements

WP-CLI must be installed on your server, with access to run it from the command line. The Activity Log plugin must be installed and activated. Run all commands from the root of your WordPress installation.

Export Command

The export command outputs activity log entries to the terminal or a file. Combine any of the flags below to filter the results.

wp duplicator-activity-log export

By default, this outputs all log entries as a formatted table. Add flags to filter the entries and change the output format.

Note: When Logging Method is set to Asynchronous (queued) in Activity Log » Settings » General, new events are saved in batches every 5 minutes. An export run right after an action may not include that action yet.

Export Flags

The following flags are available. All of them are optional, and they work in any combination:

  • --format=
    Output format. Accepts table (default), csv, or json.
  • --category_l1=
    Filter by top-level event category. Accepted values: user, content, media, plugin, theme, wordpress, appearance, taxonomy, settings.
  • --severity=
    Filter by severity level. Accepted values: info, low, medium, high, critical.
  • --user_id=
    Filter events by a specific WordPress user ID.
  • --event_type=
    Filter by a specific event type code, for example: user_login_failed, plugin_activated, content_post_published.
  • --search=
    Search across event messages, usernames, and object names. Equivalent to the Search Events field in the admin.
  • --date_from=
    Show events from this date onward. Use the YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format. Dates and times are in UTC.
  • --date_to=
    Show events up to this date and time. Uses the same format as --date_from=. A date on its own means midnight at the start of that day, so events from that day are left out. To include the whole day, add the time, for example --date_to="2026-01-07 23:59:59".
  • --site_id=
    On WordPress Multisite, filter events for a specific site by its blog ID. Defaults to the current site.
  • --fields=
    Comma-separated list of fields to display. This flag only applies to table format. CSV and JSON exports always include every field.

    Available fields for --fields=:
    id, date_gmt, severity, event_type, event_label, category_l1, category_l2, category_l3, message, user_id, user_login, user_role, object_type, object_id, object_name, ip_address, user_agent, request_method, request_uri, source, site_id, metadata.

Export Examples

wp duplicator-activity-log export --format=csv > activity-log.csv

Export all events as a CSV file:

Export only high severity events for a 7-day range:

wp duplicator-activity-log export --severity=high --date_from=2026-01-01 --date_to="2026-01-07 23:59:59"

Export all failed login attempts as JSON:

wp duplicator-activity-log export --event_type=user_login_failed --format=json

Export all plugin events for a specific date range to a file:

wp duplicator-activity-log export --category_l1=plugin --date_from=2026-01-01 --date_to="2026-01-31 23:59:59" --format=csv > plugins-jan.csv

Export only specific fields for a lightweight CSV:

wp duplicator-activity-log export --format=csv --fields=date_gmt,user_login,severity,message > compact-log.csv

Purge Command

The purge command deletes activity log entries directly from the command line.

wp duplicator-activity-log purge

Running purge with no flags deletes every entry in the activity log. WP-CLI asks for confirmation before deleting, unless you add --yes.

The following flags are available:

  • --older-than=<days>
    Delete only entries older than the given number of days, instead of deleting everything.
  • --yes
    Skip the confirmation prompt.

Note: Running wp duplicator-activity-log purge with no flags deletes the entire activity log, not just entries past your Log Retention period. Add --older-than=<days> to delete only older entries. Automatic retention-based cleanup runs as a separate daily scheduled task (set in Activity Log » Settings » General) and is not the same action as this command. The --older-than= value must be a whole number above 0. With 0 or a value that isn’t a number, the command offers to delete every entry.

Purge Examples

Delete all log entries, with a confirmation prompt:

wp duplicator-activity-log purge

Delete entries older than 90 days:

wp duplicator-activity-log purge --older-than=90

Delete all entries without a confirmation prompt:

wp duplicator-activity-log purge --yes

Use these commands to clean up the activity log on demand. To delete every entry from wp-admin instead, go to Activity Log » Settings » Tools and click Purge All Logs.

That’s it! You now know how to export and clean up activity log data from the command line, without opening wp-admin.

Want to change how long entries stay in the log before the daily cleanup removes them? Check out our guide on Configuring Activity Log Settings.


Was this article helpful?


Related Articles

Don't Let Another Day Pass Unprotected

Every hour without proper WordPress backups puts your site at risk • Every delayed WordPress migration costs you performance and growth

Get Duplicator Now
Duplicator Plugin

Wait! Don't miss your
exclusive deal!

As a customer, you get 60% OFF

Try Duplicator free on your site — see why 1.5M+ WordPress pros trust us. But don't wait — this exclusive 60% discount is only available for a limited time.

or
Get 60% Off Duplicator Pro Now →