Blog

Clear Discourse Logs

Discourse

You have set up a new Discourse community and, for example, after migrating the data and making subsequent adjustments, there are several thousand log entries in the "Staff Log" (Team Actions Log)? In this case, it might make sense to empty the log before going live with the new community.

Remember to create a backup before clearing the logs!

To empty the log, you first need to connect to the server via SSH.

Next, you need to open the Rails console:

cd /var/discourse
./launcher enter app
rails c

Using this command, you can check the number of log entries:

UserHistory.all.count

Then, you can delete all entries using this command:

UserHistory.destroy_all

Now, check the number of entries again:

UserHistory.all.count

The output should now be 0.

You can now exit the console using exit - your logs are cleared.