RKP
RKP

Reputation: 5385

how to set the log file path of the SSIS package programmatically

I am executing SSIS package programmatically using C# and I want to set the log file for the package by reading the path from the web.config file. I looked at the code from the link http://msdn.microsoft.com/en-us/library/ms136023.aspx. but the package already has logging enabled and file name set to some location, I just need to be able to update the log file path to a different location dynamically by reading from config file. Please let me know how to do this. thanks in advance.

Upvotes: 0

Views: 1593

Answers (1)

Garett
Garett

Reputation: 16828

You should be able to modify the ConnectionString property of the ConnectionManager, which can be retrieved from an existing package's Connections property. For example:

Application app = new Application();
Package p = app.LoadPackage(@"C:\PathToPackage", null);

// LogFileConnection is an existing connection to a log file.
ConnectionManager c = p.Connections["LogFileConnection"] as ConnectionManager;
if (c != null)
    c.ConnectionString = @"C:\SomePathToLogFile"; // Change the file path

p.Execute(); //You should now see events logged to the new file path

Upvotes: 2

Related Questions