Audit.MaximumRolloverFiles Property


Gets or sets the maximum number of rollover files allowed.

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public long MaximumRolloverFiles { get; set; }

Property Value

Type: System.Int64

An int64value that specifies the maximum number of rollover files allowed.

A rollover file is created when the audit file exceeds the maximum file size. Subsequent audit information is logged into the rollover file.

The maximum number of files you can specify is 2,147,483,647. You can set the value to 0 to specify that an unlimited number of rollover files can be created in the file system.

The following code example demonstrates how to set a maximum of 2 rollover files for the audit.


using System;
using System.Data;
using Microsoft.SqlServer.Management.Smo;

namespace samples
    class Program
        static void Main(string[] args)
            //Create the audit
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.MaximumRolloverFiles = 2;


#Create the audit 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.MaximumRolloverFiles = 2
Return to top