HtmlLogProvider Sample

New: 14 April 2006

The HtmlLogProvider sample demonstrates how to create a custom log provider, the Html Log Provider, which writes logging output to an HTML document.

For more information about how to create a custom log provider, see Creating a Custom Log Provider. For general information about the use of log providers in Integration Services, see Integration Services Log Providers.

The custom log provider obtains the name of a destination file that has the extension .htm or .html from an existing File connection manager. It outputs logged events to an HTML table in the specified destination file, ignoring the final two standard columns (dataCode and dataBytes) which may contain binary data that cannot be displayed correctly in an HTML document. The sample encapsulates the HTML logging code in a separate HtmlLogWriter helper class for ease of reuse. This helper class has OpenLogHtml, LogHtml, and CloseLogHtml subroutines, which are called from OpenLog, Log, and CloseLog respectively. This sample is not supported on Itanium-based operating systems.

This code sample implements the following functionality:

  • Overriding of the LogProviderBase class.
  • Default persistence support that does not require the developer to write custom persistence code.

Important

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

Running the Sample

If you already know how to locate, build, and install code samples, you can go directly to the section Testing the Sample, and read about how to configure and run the code sample.

Prerequisites

This sample requires that the following components are installed.

  • Microsoft Visual Studio 2005
  • Microsoft SQL Server 2005 Integration Services

Location

If the code sample was installed to the default location, the sample is located in the following directory:

C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\\Programming Samples\Control Flow\HtmlLogProvider Sample

The C# solution for the code sample is located in the CS directory, and the Visual Basic solution is located in the VB directory.

For information about the two-step process required to install the samples, see Installing Samples. To obtain the latest version of the samples, including new samples released after the original release of SQL Server 2005, see SQL Server 2005 Samples and Sample Databases (April 2006).

Building the Sample

If you have not already generated a strong name key file in the Samples folder, use the following procedure to generate this key file. The sample projects are configured on the Signing tab of the Project Properties dialog box to sign assemblies at build time with this key file.

To generate a strong name key file

  1. To open a Microsoft Visual Studio 2005 command prompt, click Start, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.

    - or -

    To open a Microsoft .NET Framework command prompt, click Start, point to All Programs, point to Microsoft .NET Framework SDK v2.0, and then click SDK Command Prompt.

  2. At the command prompt, use the change directory (CD) command to change the current folder of the command prompt to the Samples folder. The key file that you create in this folder will be used by all SQL Server 2005 code samples.

    Note

    To determine the folder where samples are located, click Start, point to All Programs, point to Microsoft SQL Server 2005, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\90\Samples.

  3. At the command prompt, run the following command to generate the key file:

    sn -k SampleKey.snk
    

    Important

    For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.

To build the sample in Microsoft Visual Studio 2005

  1. From the File | Open menu, click Project and open the HtmlLogProviderVB.sln or HtmlLogProviderCS.sln.

  2. On the Build menu, click Build Solution to build the solution.

Installing the Sample

This sample is provided in both Visual Basic and C#. To distinguish the assemblies for each version of the sample, the name of the output assembly has CS or VB appended. After successfully building the component, follow these steps in order to add it as a connection manager in a package in Business Intelligence Development Studio.

To copy the component to the Connections folder

  1. Open Windows Explorer or your preferred application for working in the file system.

  2. Copy the assembly (HtmlLogProviderCS.dll or HtmlLogProviderVB.dll) to the LogProviders folder located at %system%\Program Files\Microsoft SQL Server\90\DTS.

To install the component into the global assembly cache (GAC) by dragging and dropping the assemblies

  1. Open Windows Explorer or your preferred application for working in the file system.

  2. Drag the assembly from the LogProviders folder to the folder where the global assembly cache (GAC) is located, at %system%\assembly.

To install the component into the global assembly cache (GAC) by using gacutil.exe

  1. Open a Command Prompt window.

  2. Type the following commands to install the C# version of the component into the GAC:

    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\HtmlLogProvider Sample\CS\HtmlLogProviderCS\bin\Debug\HtmlLogProviderCS.dll"
    

    - or -

    Type the following commands to install the Visual Basic version of the component into the GAC:

    gacutil.exe -iF " C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Programming Samples\Control Flow\HtmlLogProvider Sample\VB\HtmlLogProviderVB\bin\Debug\HtmlLogProviderVB.dll"
    

Testing the Sample

You can now test the custom log provider in a package.

To use the sample log provider in a package

  1. In an Integration Services project, add a new File connection manager and configure it to point to a file that has the extension **.**htm or **.**html.

  2. From the SSIS menu, select Logging, and add the Custom log provider for HTML files (CS) or Custom log provider for HTML files (VB).

  3. In the Configuration column, enter the name of the File connection manager.

  4. Configure logging as appropriate so that the package and its components log their events to the custom log provider.

  5. Run the package, and then open the HTML file to view the logging output.