Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2008, 04:57 AM
Registered User
 
Join Date: Sep 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Programmatically Add/Customize SSIS built in Loggi

Hi,



Please anybody help me to resolve the problem related to SSIS logging.

I want to customize SSIS logging . I have created one SQL script Task which contains the following code ......



public void Main()

{

try

{

CreatePackageLogProvider();

Dts.TaskResult = (int)ScriptResults.Success;

}

catch (Exception ex)

{

MessageBox.Show("Error in script: " + ex.Message);

}

}

public void CreatePackageLogProvider()

{

try

{

Package p = new Package();

ConnectionManager dbConMgr = p.Connections.Add("OLEDB");

dbConMgr.Name = "SQL2008.BE_ETLDB";

dbConMgr.ConnectionString = @"Data Source=WPNQ1109104448\SQL2008;User ID=appwriter;Password=fastwriter;Initial Catalog=BE_ETLDB;Provider=SQLNCLI10.1;Persist Security Info=True;";

LogProvider logProvider = p.LogProviders.Add("DTS.LogProviderSQLServer");

logProvider.ConfigString = "SQL2008.BE_ETLDB";

p.LoggingOptions.SelectedLogProviders.Add(logProvi der);

p.LoggingOptions.EventFilterKind = DTSEventFilterKind.Inclusion;

//p.LoggingOptions.EventFilter = new string[] { "OnInformation", "OnProgress", "OnWarning", "OnError" };

//p.LoggingOptions.EventFilter = new string[] {"PackageStart","PackageEnd","OnInformation", "OnProgress", "OnWarning", "OnError" };

p.LoggingOptions.EventFilter = new string[] { "OnInformation", "OnWarning" };

DTSEventColumnFilter ecf = new DTSEventColumnFilter();

// Set the detailed information to log when the event occurs.

// This specifies to log the Computer, Operator, and SourceName only.

ecf.Computer = true;

ecf.Operator = true;

ecf.SourceName = true;

ecf.SourceID = false;

ecf.ExecutionID = false;

ecf.MessageText = true;

ecf.DataBytes = false;

// The event is the first parameter, and the columns to log is the enumeration.

//p.LoggingOptions.SetColumnFilter("OnError", ecf);

p.LoggingOptions.SetColumnFilter("OnWarning", ecf);

//p.LoggingOptions.SetColumnFilter("OnProgress", ecf);

p.LoggingOptions.SetColumnFilter("OnInformation", ecf);

p.LoggingMode = DTSLoggingMode.Enabled;

string[] strArr = p.LoggingOptions.GetColumnFilteredEvents(); // Just for testing

DTSEventColumnFilter newECF = new DTSEventColumnFilter();

p.LoggingOptions.GetColumnFilter("OnInformation", ref newECF);

p.LoggingOptions.GetColumnFilter("OnWarning", ref newECF);

logProvider.OpenLog();

bool fireAgain = false;

Dts.Events.FireInformation(1, "Fire events", "FireInformation from script", "", 0, ref fireAgain);

p.Execute(); // It must be executed

Dts.Events.FireWarning(2, "Warning component", "Warning generated from script", null, 0);

Dts.Events.FireInformation(2, "Fire events", "FireInformation from script", "", 0, ref fireAgain);

//logProvider.CloseLog(); // should be call at the end of package execution

}

catch (Exception ex)

{

throw ex;

}

}



This code is executing successfully and 'sysssislog' table is also created in BE_ETLDB database. But the problem is that even if I have set event filter for OnWarning and OnInformation , it is only logging for 'PackageStart' and 'PackageEnd'
 events , so after executing this package the sysssislog table just contains 2 records. However I want to log user specified events. Actaully I want to add event filter for built in SSIS logging ,so that user can set the that filter through SSIS configuration table.

Please let me know Am I doing anything wrong with the aboce code ?









Similar Threads
Thread Thread Starter Forum Replies Last Post
Customize Datagrid Mohamed_sherief ASP.NET 2.0 Professional 5 August 23rd, 2007 09:31 PM
customize Paula222 ASP.NET 2.0 Professional 0 November 9th, 2006 12:19 AM
customize menu Paula222 ASP.NET 2.0 Basics 0 November 9th, 2006 12:19 AM
How to add a datagridcombobox programmatically ? maximus101 VB Databases Basics 1 October 23rd, 2006 03:08 PM
SSIS - Built-In Logging / Custom Logging ivobecker23 SQL Server 2005 0 April 21st, 2006 05:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.