How to clear the SharePoint Usage Logs and/or Web

2019-05-29 04:01发布

问题:

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.

回答1:

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.



回答2:

If you are just trying to restart the logging, try: ◦Open the ​"SharePoint 2010 Management Shell" (Powershell for SharePoint). ◦Type "New-SPLogFile"

Done.

The logs will be in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS"