Truncating the EventLog and ScheduleHistory Table in Versions 7.4.0 and Above

Overview

The Event Log and Schedule History records all the activities that occur throughout the DNN environment. Without proper management, these logs can grow to be very large and affect performance. This article details on how to clear out the tables.

 

Prerequisites

 

Diagnosis

NOTE: A database backup should be performed before running the attached script. Additionally, it's advisable that this is done outside of business hours as the process could take some time to complete. 

The DNN event log stores each exception and all other registered events in the database. There is a scheduler job that users should have enabled to ensure the table doesn't grow too large and cause performance issues. However, if the job is turned off or there were many events between executions of the scheduler, the cleanup job and even a manual deletion command might time out. 

In this case, truncating the table is the only option, as it purges all rows from the database table efficiently and without logging. While it was quite easy to run this command before, in DNN 7.4.0 and up, the EventLog table was split into three tables which are linked by Foreign Key Constraints to implementing referential integrity. This prevents you from simply applying the Truncate Table action.

 

Solution

  1. Access the Settings > SQL Console or SQL Server Management Studio
  2. Execute the attached script 
  3. Run the query: TRUNCATE TABLE ScheduleHistory
  4. Clear Cache

The logs should be completely cleared out.

 

Testing

To test that the logs have been cleared out by:

  1. Go to Manage > Admin Logs to see if the Event logs are empty.
  2. Go to Settings > Scheduler > History to see if the Schedule History is empty.

Attachments

Comments

0 comments

Please sign in to leave a comment.