Audit.MaximumFileSize 속성

Gets or sets the maximum size of the audit in megabytes.

네임스페이스:  Microsoft.SqlServer.Management.Smo
어셈블리:  Microsoft.SqlServer.Smo(Microsoft.SqlServer.Smo.dll)

구문

‘선언
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public Property MaximumFileSize As Integer 
    Get 
    Set
‘사용 방법
Dim instance As Audit 
Dim value As Integer 

value = instance.MaximumFileSize

instance.MaximumFileSize = value
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public int MaximumFileSize { get; set; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property int MaximumFileSize {
    int get ();
    void set (int value);
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member MaximumFileSize : int with get, set
function get MaximumFileSize () : int 
function set MaximumFileSize (value : int)

속성 값

유형: System.Int32
A Int64 value that specifies the maximum size of the audit in megabytes.

주의

The minimum size that you can specify is 1024 KB and the maximum is 2,147,483,647 terabytes. You can also specify 0, which does not place a limit on the size of the file. If you specify a value lower than 1024, an error is raised.

The following code example shows how to set the maximum size of the audit log file to 10 megabytes and display that information on the console.

C#

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

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit and set the maximum file size
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.MaximumFileSize = (int)10;
            dbAudit.Create()
                       
            //Display the maximum file size on the console
            Console.WriteLine("The maximum size the audit log file is "
                              + dbAudit.MaximumFileSize + " 
                              megabytes.");
        }
    }
}

Powershell

#Create the audit and set the maximum file size
$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.MaximumFileSize = 10
$dbAudit.Create()

#Display the maximum file size
Write-Host "The maximum size of the audit log file is:" 
           $dbAudit.MaximumFileSize "megabytes."

참고 항목

참조

Audit 클래스

Microsoft.SqlServer.Management.Smo 네임스페이스