Share via


LogProviders.Add(String) Methode

Definition

Fügt am Ende der Auflistung den angegebenen Protokollanbieter hinzu.

public:
 Microsoft::SqlServer::Dts::Runtime::LogProvider ^ Add(System::String ^ logProviderClsidOrProgId);
public Microsoft.SqlServer.Dts.Runtime.LogProvider Add (string logProviderClsidOrProgId);
member this.Add : string -> Microsoft.SqlServer.Dts.Runtime.LogProvider
Public Function Add (logProviderClsidOrProgId As String) As LogProvider

Parameter

logProviderClsidOrProgId
String

Die Klassen-ID oder ProgID des Protokollanbieters, der der Auflistung hinzugefügt werden soll.

Gibt zurück

LogProvider

Das der Auflistung hinzugefügte LogProvider-Objekt.

Beispiele

Im folgenden Codebeispiel wird der Sammlung mithilfe seiner ProgID der SQL Server-Protokollanbieter hinzugefügt. Beachten Sie in der Konsolenausgabe aus der foreach C#-Schleife die Position in der Auflistung und den Namen, der dem neu hinzugefügten Protokollanbieter zugewiesen ist.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace LogProviders_Tests  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            // The package is one of the SSIS Samples.  
            string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";  

            // Create the Application, and load the sample.  
            Application app = new Application();  
            Package pkg = app.LoadPackage(mySample, null);  
            LogProviders logProvs = pkg.LogProviders;  

            // Count the number of providers in the package.  
            int countProvs = logProvs.Count;  
            Console.WriteLine("Initial number of log providers: {0}", countProvs);  

            // Since the package that was loaded only contained the  
            // SSIS Log provider for Text files, let's add the SQL  
            // Server log provider.  
            LogProvider logProv = pkg.LogProviders.Add("DTS.LogProviderSQLServer.1");  

            // Count how many log providers are in the collection now.  
            countProvs = logProvs.Count;  
            Console.WriteLine("The number of log providers now: {0}", countProvs);  
            Console.WriteLine("----------------------------");  

            foreach (LogProvider lp in logProvs)  
            {  
                Console.WriteLine("Log Provider Name: {0}", lp.Name);  
            }  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace LogProviders_Tests  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            ' The package is one of the SSIS Samples.  
            Dim mySample As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"   

            ' Create the Application, and load the sample.  
            Dim app As Application =  New Application()   
            Dim pkg As Package =  app.LoadPackage(mySample,Nothing)   
            Dim logProvs As LogProviders =  pkg.LogProviders   

            ' Count the number of providers in the package.  
            Dim countProvs As Integer =  logProvs.Count   
            Console.WriteLine("Initial number of log providers: {0}", countProvs)  

            ' Since the package that was loaded only contained the  
            ' SSIS Log provider for Text files, let's add the SQL  
            ' Server log provider.  
            Dim logProv As LogProvider =  pkg.LogProviders.Add("DTS.LogProviderSQLServer.1")   

            ' Count how many log providers are in the collection now.  
            countProvs = logProvs.Count  
            Console.WriteLine("The number of log providers now: {0}", countProvs)  
            Console.WriteLine("----------------------------")  

            Dim lp As LogProvider  
            For Each lp In logProvs  
                Console.WriteLine("Log Provider Name: {0}", lp.Name)  
            Next  
        End Sub  
    End Class  
End Namespace  

Beispielausgabe:

Erste Anzahl von Protokollanbietern: 1

Die Anzahl der Protokollanbieter jetzt: 2

----------------------------

Protokollanbietername: {FCA3ACD4-C080-4B67-A1AA-45118D3DA672}

Protokollanbietername: SSIS-Protokollanbieter für Textdateien

Hinweise

Wenn Sie der Auflistung einen Protokollanbieter hinzufügen, können Sie ihn mithilfe seiner ClassID (GUID) oder ProgID hinzufügen. In der folgenden Liste sind die verfügbaren Logger und ihre IDs aufgeführt.

Textdatei:

  • ProgID: DTS.LogProviderTextFile.1

  • ClassID: {59B2C6A5-663F-4C20-8863-C83F9B72E2EB}

SQL Server Profiler:

  • ProgID: DTS.LogProviderSQLProfiler.1

  • ClassID: {5C0B8D21-E9AA-462E-BA34-30FF5F7A42A1}

SQL Server:

  • ProgID: DTS.LogProviderSQLServer.1

  • ClassID: {6AA833A1-E4B2-4431-831B-DE695049DC61}

Windows-Ereignisprotokoll:

  • ProgID: DTS.LogProviderEventLog.1

  • ClassID: {97634F75-1DC7-4F1F-8A4C-DAF0E13AAA22}

XML-Datei:

  • ProgID: DTS.LogProviderXMLFile.1

  • ClassID: {AFED6884-619C-484F-9A09-F42D56E1A7EA}

Gilt für: