Audit.DestinationType Audit.DestinationType Audit.DestinationType Property

Definition

Gets or sets the type of destination to which the audit log information is recorded, such as a file, or an application log.

public:
 property Microsoft::SqlServer::Management::Smo::AuditDestinationType DestinationType { Microsoft::SqlServer::Management::Smo::AuditDestinationType get(); void set(Microsoft::SqlServer::Management::Smo::AuditDestinationType value); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcProperty(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Standalone)]
public Microsoft.SqlServer.Management.Smo.AuditDestinationType DestinationType { get; set; }
Public Property DestinationType As AuditDestinationType
Property Value

A AuditDestinationType object that represents the type of destination to which the audit log information is logged.

Examples

The following code example shows how to set the audit destination type to a Windows Security event log.

C#

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

namespace samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            //Create the audit and set the destination file type  
            Server dbServer = new Server("(local)");  
            Audit dbAudit = new Audit(dbServer, "Test Audit");  
            dbAudit.DestinationType = AuditDestinationType.SecurityLog;  
            dbAudit.FilePath = "C:\\AuditDirectory";  
            dbAudit.Create();  
        }  
    }  
}  

Powershell

#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.Create()  

Applies to