SharePoint 2010/2013/2016 Audit Log Trimming

Posted on Posted in SharePoint Server

In this blog we see how to trim the SharePoint 2010/2013/2016 audit logs.

We need to trim logs when storage is full, this is due to we didn’t implement a proper trimming of Audit logs, you can use below PowerShell command to delete them:

$site = Get-SPSite https://yoursite.yourdomain.com
$date = Get-Date "04/10/2017"
$site.Audit.DeleteEntries($date)

You need to make sure you have enough free space on your log drive.

However, SharePoint 2013/2016 offers the option of audit logs, see the below link for detailed:

Configure audit settings for a site collection

There is a setting available i.e. to trim the audit logs and optionally save the trimmed data into a library. Stated in above article which is by default is every 30 days, but you can change the log retention to some other value as per our requirement.

If you want to change retention log to other than the default say 10 days. Then make sure that you also set the schedule of the corresponding timer job to match your retention schedule.

As each web application have its own Audit Log Trimming job and the default timer job is scheduled for monthly, so if you want to have retention of 10 days then set the schedule of the timer jobs to 10 and test the results.

By following above steps you can easily trim the SharePoint 2010/2013/2016 audit logs.

Leave a Reply

Your email address will not be published. Required fields are marked *