Trimauditlog: Stsadm operation (Office SharePoint Server)

Applies To: Office SharePoint Server 2007

This Office product will reach end of support on October 10, 2017. To stay supported, you will need to upgrade. For more information, see , Resources to help you upgrade your Office 2007 servers and clients.


Topic Last Modified: 2016-11-14

Operation name: Trimauditlog


Lets an administrator delete audit entries older than a certain date, as specified by using the date parameter.


This operation is available after the Infrastructure Update for Microsoft Office Servers is installed. This functionality is available only by using Stsadm.


stsadm -o trimauditlog

**   -url <URL name>**

**   -date <YYYYMMDD>**

**   -databasename <database name>**

**\[-databaseserver\] \<database server name\>**

**   –orphanedentries**


Parameter Value Required? Description


A valid URL, such as http://server_name

Yes, if databasename parameter is not specified

Specifies the URL name to a site collection. If you use this parameter, it will only delete the audit entries from that site collection. If this parameter is used, the databaseserver and databasename parameters are ignored.


A valid date in the form "YYYYMMDD"


Represents the earliest date and time for which the user wants to preserve audit data.

databasename (dn)

A valid database name, such as "DB1"

Yes, if url parameter is not specifed

Specifies the name of a content database where the audit log should be trimmed.

databaseserver (ds)

A valid database server, such as "DS1"


Name of the database server where the content database is stored.


If your database server and SharePoint Products and Technologies are hosted on separate servers, you need to use the databaseserver parameter to specify the database server name.




Trims the audit data that is missed when you run the Stsadm trimauditlog operation.


The only time you need to use the orphanedentries parameter is when you delete a Microsoft Office SharePoint Server site collection and use the stsadm -o trimauditlog operation to trim the audit data but it misses some of the audit data.


For situations in which you want to provide additional parameters beside a date to delete audit entries, see SPAudit.DeleteEntries Method (Microsoft.SharePoint) (

If you want to export the current log before deleting it, custom code can be written using the SPAudit Class (Microsoft.SharePoint) (


The audit entries are permanently deleted after this operation has run.

An administrator can use Windows Task Scheduling to set this trim job to reoccur according to a defined period. For additional information about Windows Scheduling, see SharePoint Timer job reference (Office SharePoint Server).


Your audit log is growing too fast and you want to trim some entries from it. To specify a date of July 4, 2008, and the content database name WSSContent123456, you would use the following syntax:

stsadm -o trimauditlog –date 20080704 –databasename WSSContent123456

You delete a site collection and you need to trim the audit data. You first use the stsadm -o trimauditlog command but it misses some of the audit data. You need to use the orphanedentries parameter to trim all of the audit data. You can use either the databasename or databaseserver parameters to specify the database name or the name of the database server.

stsadm -o trimauditlog –orphanedentries –databasename <database name> [–databaseserver <database server name>]