August 21, 2012 at 9:58 am
Hi I am trying to implement logging in SSIS packages programmatically. The idea is to build the package first in the BIDS designer and then, since defining logging in the designer itself seems a little cumbersome(opening the log config box and then clicking the package and all the executables below it and the clicking all the options etc), i am trying to do that programatically.
I can do that at the Package level. My question is, can i do that programmatically for the all the executables(or as desired) inside of the package. I was trying to do something like the below but it doesn't work :
Package p1 = (Package)p.Executables[4];
p1.LoggingOptions.EventFilterKind = DTSEventFilterKind.Exclusion;
p1.LoggingOptions.EventFilter = new String[] { "OnError", "OnWarning", "OnInformation" };
p1.LoggingMode = DTSLoggingMode.Enabled;
Obviously, it throws an error at the cast.
Any help woild be welcome.
Regards
August 21, 2012 at 3:12 pm
Hi friends
just figured out the answer.....if it helps anybody at all. the below is what i did to make it work :
//You can first check for p.Executables.count > 0
foreach (Executable exe in p.Executables)
{
DtsContainer dc = (DtsContainer)exe;
dc.LoggingOptions.EventFilterKind = DTSEventFilterKind.Inclusion;
dc.LoggingOptions.EventFilter = new String[] { "OnError", "OnTaskFailed" }; //and anyother filter you want to add
dc.LoggingMode = DTSLoggingMode.Enabled;
}
Basically, even as i posted the question, i was thinking how to cast an 'Executable' to the appropriate type(because Executable type itself did not expose properties like LoggingOptions etc). then realized, the base type is Container and any Container would have such methods / properties.
Regards
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply