Audit.FilePath プロパティ

監査の種類がファイルである場合に、監査ファイルが格納されるフォルダーの場所を取得または設定します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public Property FilePath As String 
    Get 
    Set
'使用
Dim instance As Audit 
Dim value As String 

value = instance.FilePath

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

プロパティ値

型: System.String
監査ログ情報の記録先のファイルのパスを指定する String 値。

説明

監査ログの記録先の種類は、AuditDestinationType プロパティを使用して設定できます。

使用例

次のコード例では、記録先の監査ログ ファイルのパスを取得する方法を示します。

C#

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

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

            //Display the path of the audit log file on the console
            Console.Writeline("The path of the audit log file is: " +
                              dbAudit.FilePath);
        }
    }
}

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()

#Display the path of the audit log file
Write-Host "The path of the audit log file is:" $dbAudit.FilePath

関連項目

参照

Audit クラス

Microsoft.SqlServer.Management.Smo 名前空間