Steps to Clear All Logs - Xenforo (Except Error Logs Which Can Be Cleared via ACP)
well-known master
Staff member
Owner
Steps to Clear All Logs (Except Error Logs Which Can Be Cleared via ACP)
Warning
Database Backup: Before proceeding, back up your database via phpMyAdmin or a similar tool to prevent unwanted data loss.
Caution: Deleting logs is permanent and cannot be undone unless you have a backup.
Permissions: Make sure you have access to the database and understand the risks.
1. Access the Database
Log into phpMyAdmin or the database management tool you are using.
Select your XenForo database (usually the database name is specified during installation).
2. Identify the Log Tables
XenForo stores logs in the following tables in the database:
xf_admin_log: Log of admin activity in ACP.
xf_moderator_log: Log of moderator activity.
xf_change_log: Log of user profile changes (e.g. username, email).
xf_spam_trigger_log: Log of spam triggers.
xf_spam_cleaner_log: Spam cleaner usage log.
xf_payment_provider_log: Payment transaction log.
xf_image_proxy_log: Image proxy log.
xf_link_proxy_log: Link proxy log.
xf_oembed_log: Media oEmbed log.
xf_sitemap_log: Sitemap creation log.
xf_cookie_consent_log: Cookie consent log.
(and others depending on the add-on or feature enabled)
Note: xf_error_log (Server Error Log) can be deleted directly via ACP in Tools > Server Error Log, so we focus on other tables.
3. Delete All Log Entries
To delete all entries in the log table, run the following SQL commands one by one in phpMyAdmin ("SQL" tab):
Delete Admin Log:
sql
TRUNCATE TABLE xf_admin_log;
Remove Log Moderator:
sql
TRUNCATE TABLE xf_moderator_log;
Delete User Change Log:
sql
TRUNCATE TABLE xf_change_log;
Delete Spam Trigger Log:
sql
TRUNCATE TABLE xf_spam_trigger_log;
Delete Spam Cleaner Log:
sql
TRUNCATE TABLE xf_spam_cleaner_log;
Delete Payment Provider Log:
sql
TRUNCATE TABLE xf_payment_provider_log;
Delete Image Proxy Log:
sql
TRUNCATE TABLE xf_image_proxy_log;
Delete Link Proxy Log:
sql
TRUNCATE TABLE xf_link_proxy_log;
Delete oEmbed Log:
sql
TRUNCATE TABLE xf_oembed_log;
Delete Sitemap Log:
sql
TRUNCATE TABLE xf_sitemap_log;
Delete Cookie Consent Log:
sql
TRUNCATE TABLE xf_cookie_consent_log;
Explanation:
TRUNCATE TABLE will delete all data in that table and reset the ID to 0. This is faster than DELETE FROM.
4. Run Commands
Copy and paste the commands above one by one into the SQL tab in phpMyAdmin.
Click "Go" to execute each command.
Repeat for each table you want to delete.
5. Verify
Go back to the XenForo ACP (e.g. Logs > Moderator Log) and check that the log is empty.
Alternative: Set Automatic Pruning
If you don't want to manually delete it repeatedly, XenForo has an automatic pruning option for some logs:
Moderator Log:
Go to ACP > Setup > Options > Logging Options.
Set the "Moderator log length" (default 60 days) to a smaller value, e.g. 1 day.
User Change Log:
In the same options, set the "User change log length".
Admin Log:
There is no option in the ACP. Add it to src/config.php:
php
$config['adminLogLength'] = 7; // In days, e.g. 7 days
Other logs such as spam triggers or payment providers will be pruned automatically by the system (usually after 30-90 days, depending on internal configuration), but there is no direct option to set this via the ACP.
Important Notes
Security: The Admin Log is intentionally not purgeable via ACP to maintain an audit trail in case of a security breach.
Add-ons: If you are using add-ons, there may be additional log tables. Search the database with the xf_ prefix to be sure.
Risk: Purging the logs may affect your ability to track down issues in the future.
If you have tried this and are still having problems (e.g. the logs are not purged or the tables are not found), let me know the details, such as error messages or what you are seeing in ACP!

Warning
Database Backup: Before proceeding, back up your database via phpMyAdmin or a similar tool to prevent unwanted data loss.
Caution: Deleting logs is permanent and cannot be undone unless you have a backup.
Permissions: Make sure you have access to the database and understand the risks.
1. Access the Database
Log into phpMyAdmin or the database management tool you are using.
Select your XenForo database (usually the database name is specified during installation).
2. Identify the Log Tables
XenForo stores logs in the following tables in the database:
xf_admin_log: Log of admin activity in ACP.
xf_moderator_log: Log of moderator activity.
xf_change_log: Log of user profile changes (e.g. username, email).
xf_spam_trigger_log: Log of spam triggers.
xf_spam_cleaner_log: Spam cleaner usage log.
xf_payment_provider_log: Payment transaction log.
xf_image_proxy_log: Image proxy log.
xf_link_proxy_log: Link proxy log.
xf_oembed_log: Media oEmbed log.
xf_sitemap_log: Sitemap creation log.
xf_cookie_consent_log: Cookie consent log.
(and others depending on the add-on or feature enabled)
Note: xf_error_log (Server Error Log) can be deleted directly via ACP in Tools > Server Error Log, so we focus on other tables.
3. Delete All Log Entries
To delete all entries in the log table, run the following SQL commands one by one in phpMyAdmin ("SQL" tab):
Delete Admin Log:
sql
TRUNCATE TABLE xf_admin_log;
Remove Log Moderator:
sql
TRUNCATE TABLE xf_moderator_log;
Delete User Change Log:
sql
TRUNCATE TABLE xf_change_log;
Delete Spam Trigger Log:
sql
TRUNCATE TABLE xf_spam_trigger_log;
Delete Spam Cleaner Log:
sql
TRUNCATE TABLE xf_spam_cleaner_log;
Delete Payment Provider Log:
sql
TRUNCATE TABLE xf_payment_provider_log;
Delete Image Proxy Log:
sql
TRUNCATE TABLE xf_image_proxy_log;
Delete Link Proxy Log:
sql
TRUNCATE TABLE xf_link_proxy_log;
Delete oEmbed Log:
sql
TRUNCATE TABLE xf_oembed_log;
Delete Sitemap Log:
sql
TRUNCATE TABLE xf_sitemap_log;
Delete Cookie Consent Log:
sql
TRUNCATE TABLE xf_cookie_consent_log;
Explanation:
TRUNCATE TABLE will delete all data in that table and reset the ID to 0. This is faster than DELETE FROM.
4. Run Commands
Copy and paste the commands above one by one into the SQL tab in phpMyAdmin.
Click "Go" to execute each command.
Repeat for each table you want to delete.
5. Verify
Go back to the XenForo ACP (e.g. Logs > Moderator Log) and check that the log is empty.
Alternative: Set Automatic Pruning
If you don't want to manually delete it repeatedly, XenForo has an automatic pruning option for some logs:
Moderator Log:
Go to ACP > Setup > Options > Logging Options.
Set the "Moderator log length" (default 60 days) to a smaller value, e.g. 1 day.
User Change Log:
In the same options, set the "User change log length".
Admin Log:
There is no option in the ACP. Add it to src/config.php:
php
$config['adminLogLength'] = 7; // In days, e.g. 7 days
Other logs such as spam triggers or payment providers will be pruned automatically by the system (usually after 30-90 days, depending on internal configuration), but there is no direct option to set this via the ACP.
Important Notes
Security: The Admin Log is intentionally not purgeable via ACP to maintain an audit trail in case of a security breach.
Add-ons: If you are using add-ons, there may be additional log tables. Search the database with the xf_ prefix to be sure.
Risk: Purging the logs may affect your ability to track down issues in the future.
If you have tried this and are still having problems (e.g. the logs are not purged or the tables are not found), let me know the details, such as error messages or what you are seeing in ACP!

Relate Threads
