Search code examples
sharepointsharepoint-2010

How to clear the SharePoint Usage Logs and/or Web Analytics Logs


How do I clear the SharePoint Usage Logs and/or Web Analytics Logs? I've tried deleting the *.usage files found in {SharePoint Hive}\Logs, and deleting the Usage Service Application as well as the Web Analytics Service Application?

The reason why I as is because I have a web part that determines the most visited sites. In my code I use the

SPWeb.GetUsageData(SPUsageReportType.url, SPUsagePeriodType.lastMonth)

method, and it always returns the same data. I would like to reset the values it returns.


Solution

  • Have you tried looking at the usage database? Usage might be backed by that database.

    You can also limit the retention timeframe for specific usage items: Set-SPUsageDefinition -Identity"Page Requests" -DaysRetained 3 or see this blog post: How to reduce the size of logging database OR How to purge the old data from Logging Database.

    Another way of clearing the logs is shown here using only central admin: How to Delete Usage Logs on Sharepoint. Sahhil Malik shows yet more ways to refresh the logs: SharePoint 2010 - Drives are running out of free space.